Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
100% found this document useful (2 votes)
9 views

PDF Django 2.2 & Python: The Ultimate Web Development Bootcamp: Build three complete websites, learn back and front-end web development, and publish your site online with DigitalOcean. Alam download

Build

Uploaded by

udhinlommel
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (2 votes)
9 views

PDF Django 2.2 & Python: The Ultimate Web Development Bootcamp: Build three complete websites, learn back and front-end web development, and publish your site online with DigitalOcean. Alam download

Build

Uploaded by

udhinlommel
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 66

Download Full Version ebookmass - Visit ebookmass.

com

Django 2.2 & Python: The Ultimate Web Development


Bootcamp: Build three complete websites, learn
back and front-end web development, and publish
your site online with DigitalOcean. Alam
https://ebookmass.com/product/django-2-2-python-the-
ultimate-web-development-bootcamp-build-three-complete-
websites-learn-back-and-front-end-web-development-and-
publish-your-site-online-with-digitalocean-alam/

OR CLICK HERE

DOWLOAD NOW

Discover More Ebook - Explore Now at ebookmass.com


Instant digital products (PDF, ePub, MOBI) ready for you
Download now and discover formats that fit your needs...

Kotlin for Web Development and Kotlin Collections: A


Beginner's Odyssey in Web Development 2 Books in 1 Jp
Parker
https://ebookmass.com/product/kotlin-for-web-development-and-kotlin-
collections-a-beginners-odyssey-in-web-development-2-books-in-1-jp-
parker/
ebookmass.com

Database-Driven Web Development: Learn to Operate at a


Professional Level with PERL and MySQL 2nd Edition Thomas
Valentine
https://ebookmass.com/product/database-driven-web-development-learn-
to-operate-at-a-professional-level-with-perl-and-mysql-2nd-edition-
thomas-valentine/
ebookmass.com

Learn Enough Ruby to Be Dangerous Michael Hartl

https://ebookmass.com/product/learn-enough-ruby-to-be-dangerous-
michael-hartl/

ebookmass.com

Biotechnological production of bioactive compounds Chandel

https://ebookmass.com/product/biotechnological-production-of-
bioactive-compounds-chandel/

ebookmass.com
Blackout (John Milton 10) (German Edition) Dawson

https://ebookmass.com/product/blackout-john-milton-10-german-edition-
dawson/

ebookmass.com

Environmental Crime and Restorative Justice: Justice as


Meaningful Involvement 1st ed. 2021 Edition Mark Hamilton

https://ebookmass.com/product/environmental-crime-and-restorative-
justice-justice-as-meaningful-involvement-1st-ed-2021-edition-mark-
hamilton/
ebookmass.com

Towards the Next Revolution in Central Banking: A Radical


Framework for Monetary Policy Wehner

https://ebookmass.com/product/towards-the-next-revolution-in-central-
banking-a-radical-framework-for-monetary-policy-wehner/

ebookmass.com

Even If We Break Marieke Nijkamp

https://ebookmass.com/product/even-if-we-break-marieke-nijkamp/

ebookmass.com

Environmental Applications of Microbial Nanotechnology:


Emerging Trends in Environmental Remediation Pardeep Singh

https://ebookmass.com/product/environmental-applications-of-microbial-
nanotechnology-emerging-trends-in-environmental-remediation-pardeep-
singh/
ebookmass.com
Breaker’s Vow (Satan's Raiders MC Book 5) Elizabeth Knox &
Lena Bourne

https://ebookmass.com/product/breakers-vow-satans-raiders-mc-
book-5-elizabeth-knox-lena-bourne/

ebookmass.com
Course Content
~ Introduction
Section 1: Python Refresher
Chapter 1: Install Python
Chapter 2: Variables, Strings, Ints, and Print
Chapter 3: If Statements and Comments
Chapter 4: Functions
Chapter 5: Lists
Chapter 6: Loops
Chapter 7: Dictionaries
Chapter 8: Classes
Section 2: Project #1 - Word Counter Website
Chapter 9: Project Intro
Chapter 10: Django Cheat Sheet
Chapter 11: Installing Django
Chapter 12: Running the Django Server
Chapter 13: Project Tour
Chapter 14: URLs
Chapter 15: Templates
Chapter 16: Forms
Chapter 17: Counting the words
Chapter 18: Challenge
Chapter 19: Solution
Section 3: Git
Chapter 20: Intro to Git
Chapter 21: Installing Git A-Z
Chapter 22: Troubleshooting
Section 4: Project #2 - Your Personal Portfolio
Website
Chapter 23: Project Intro
Chapter 24: Sketch
Chapter 25: Virtualenv
Chapter 26: Gitignore
Chapter 27: Apps
Chapter 28: Models
Chapter 29: Admin
Chapter 30: psycopg2 fix
Chapter 31: Postgres
Chapter 32: Test Your Skills - Blog Model
Chapter 33: Home Page
Chapter 34: Bootstrap
Chapter 35: Show Jobs
Chapter 36: All Blogs
Chapter 37: Blog Detail
Chapter 38: Static Files
Chapter 39: Polish
Section 5: VPS
Chapter 40: Intro
Chapter 41: Digital Ocean
Chapter 42: Security
Chapter 43: Postgres and Virtualenv
Chapter 44: Git Push and Pull
Chapter 45: Gunicorn
Chapter 46: Nginx
Chapter 47: Domains
Section 6: Project #3 - Product Hunt Clone Website
Chapter 48: Project Intro
Chapter 49: Sketch
Chapter 50: Extending Templates
Chapter 51: Base Styling
Chapter 52: Sign Up
Chapter 53: Login and Logout
Chapter 54: Products Model
Chapter 55: Creating Products
Chapter 56: Iconic
Chapter 57: Product Details
Chapter 58: Home Page
Chapter 59: Polish
~ Conclusion

Introduc on
Assets and Resources:
- Django Official Website ([Visit Here](
https://www.djangoproject.com/ ))
- Python Official Website ([Visit Here](
https://www.python.org/ ))
- DigitalOcean’s Overview & Documentation ([Visit Here](
https://www.digitalocean.com/docs/ ))

Welcome to “Django 2.2 & Python: The Ultimate Web


Development Bootcamp”. This book is designed to be
your one-stop guide to mastering the powerful
combination of Django, a high-level web framework, and
Python, one of the world’s most versatile programming
languages. By the end of this bootcamp, you will not only
have built three functional web applications but will also
be equipped with the knowledge and confidence to
embark on your own web development projects.

Why Django and Python?


When venturing into the world of web development, the
sheer number of languages, frameworks, and tools can
be overwhelming. So why focus on Django and Python?
Python is celebrated for its simplicity, versatility, and
readability, making it a top choice for beginners and
seasoned developers alike. It powers a myriad of
applications, from simple scripts to machine learning
algorithms and large-scale web applications.
Django, on the other hand, was birthed from Python’s
philosophy. Often referred to as the framework “for
perfectionists with deadlines,” Django makes it
significantly faster to build high-quality web applications.
It’s designed to avoid repetitive tasks and encourage the
rapid development of robust applications, making your
development journey smoother and more enjoyable.

What’s Inside this Bootcamp?


As you delve into the upcoming sections and chapters,
here’s what you can expect:
1. Python Refresher: Even if you’ve never written a line
of Python code, we’ve got you covered. We begin with
the basics, ensuring you’re well-equipped to tackle
Django with confidence.
2. Three Comprehensive Projects: From a simple word-
counting website to your own portfolio and a clone of the
renowned Product Hunt platform, you’ll be applying your
newfound knowledge in practical, tangible ways.
3. Insights into Git: Dive into version control with Git, a
must-know tool for every developer. You’ll learn why it’s
crucial, how to set it up, and how to use it effectively.
4. Deploying with DigitalOcean: We won’t just leave you
with applications on your local machine. We’ll guide you
through deploying your projects to a Virtual Private
Server (VPS) on DigitalOcean, making them accessible
to the world.

Are You Ready?


Whether you’re a novice curious about web development
or a Python enthusiast eager to dip your toes into web
frameworks, this book is crafted for you. Our approach is
hands-on, interspersed with challenges and solutions,
ensuring you not only consume content but also actively
engage with it.
Before you dive into the next sections, ensure you have
a functioning computer and a stable internet connection.
While no prior experience with Django or Python is
required, a basic understanding of general programming
concepts will be beneficial.
And most importantly, come with an open mind and a
thirst for knowledge. The world of web development is
vast and fascinating, and we’re thrilled to be your guide
on this journey.
Prepare yourself for an immersive, enlightening, and,
above all, fun exploration of Django 2.2 and Python.
Let’s begin!

Section 1:
Python Refresher
Install Python
Assets and Resources for this Chapter:
- Python Installer: Available from the official Python
website ([Download here](
https://www.python.org/downloads/ ))
- Python Documentation: Helpful for any installation
troubleshooting or additional details ([Visit here](
https://docs.python.org/3/ ))

Introduction
Before we dive into the world of Django, it’s essential to
familiarize ourselves with the foundational language
upon which it’s built: Python. While Django is a powerful
web framework, Python is the heart and soul that powers
it. In this chapter, we’ll ensure you have Python installed
and set up correctly on your machine.

Why Python?
Python is one of the world’s most popular programming
languages. It is known for its simplicity, readability, and
vast array of libraries and frameworks, making it versatile
for everything from web development to data analysis to
artificial intelligence and more.

Choosing a Python Version


While there are multiple versions of Python available, as
of writing this book, Python 3.9 is the latest stable
release. It is always advisable to use the latest version
unless you have a specific need for an older version.
Django 2.2, which we’ll be focusing on in this book,
requires Python 3.5 or newer.
Steps to Install Python:
1. Visit the Official Python Website
- Open your browser and navigate to [Python’s official
website]( https://www.python.org/downloads/ ).
2. Download the Installer
- You’ll see a button labeled “Download Python 3.9.x”
(or the latest version). Click on it to start the download.
3. Run the Installer
- Once the download is complete, locate the installer
in your downloads folder and double-click to run it.
- Important: Ensure you check the box that says “Add
Python 3.9 to PATH” before proceeding. This will allow
you to run Python from your command line or terminal
without any extra configuration.
4. Choose Installation Options
- For most users, the default installation options will
suffice. However, if you’re an advanced user and want to
customize the installation, feel free to do so.
- Click “Install Now” to begin the installation process.
5. Installation Complete
- Once the installation is finished, you’ll see a screen
indicating that Python was installed successfully.
6. Verify the Installation
- Open your command line or terminal and type
`python —version` and press enter. This should return
the version number, confirming that Python was installed
correctly.

Potential Issues and Troubleshooting:


- If you receive an error when trying to verify the
installation, it’s possible that Python wasn’t added to
your system’s PATH. Make sure you checked the “Add
Python to PATH” option during installation.
- On some systems, you might need to use `python3`
instead of `python` to invoke Python.

Conclusion
Congratulations! You’ve successfully installed Python on
your machine. As we delve deeper into Django and web
development in the subsequent chapters, you’ll see the
power and flexibility that Python offers. But for now, take
a moment to celebrate this first step in your web
development journey. In the next chapter, we’ll dive into
some fundamental Python concepts to get you warmed
up.

Next Steps:
Before moving on, consider playing around with the
Python interactive shell by typing `python` (or `python3`
on some systems) into your command line or terminal.
This will give you a prompt where you can type and
execute Python code directly, providing an excellent way
to practice and experiment.

Variables, Strings, Ints,


and Print
Assets & Resources:
- Python (Version 3.7 or later) ([Download and install
from Python’s official website](
https://www.python.org/downloads/ ))
- A Text Editor or IDE (Recommendation: VS Code or
PyCharm)

Introduction:
Before diving deep into the world of Django and web
development, it’s crucial to have a strong foundation in
Python. This chapter will guide you through the basics of
variables, strings, integers, and the print function in
Python, setting the stage for the upcoming chapters.
1. Variables:
A variable in Python is like a container or storage
location that holds data values. A variable is assigned
with a value, and you can change this value based on
your needs.
Syntax:
“`python
variable_name = value
“`
Example:
“`python
greeting = “Hello, World!”
“`
In this example, `greeting` is a variable that holds the
string “Hello, World!”.

2. Strings:
Strings in Python are a sequence of characters,
enclosed within single (`’ ‘`) or double (`” “`) quotes.
Examples:
“`python
name = “John”
message = ‘Welcome to the world of Python!’
“`
String Concatenation:
You can also combine or concatenate strings using the
`+` operator:
“`python
first_name = “John”
last_name = “Doe”
full_name = first_name + ” ” + last_name
“`

3. Integers (Ints):
Integers are whole numbers (without decimal points). In
Python, you can perform various arithmetic operations
with integers.
Examples:
“`python
age = 25
days_in_week = 7
“`
Basic Arithmetic Operations:
“`python
sum = 5 + 3 # Addition
difference = 5 - 3 # Subtraction
product = 5 * 3 # Multiplication
quotient = 5 / 3 # Division
remainder = 5 % 3 # Modulus (returns the remainder of
the division)
“`

4. The Print Function:


The `print()` function in Python is used to output data to
the console. It’s a great tool for debugging and for
displaying results to users.
Syntax:
“`python
print(value1, value2, …, sep=’ ‘, end=’\n’)
“`
Examples:
“`python
print(“Hello, World!”)
print(“Your age is:”, age)
print(first_name, last_name, sep=” “, end=”!\n”)
“`
In the last example, `sep` is used to define a separator
between the values, and `end` defines what to print at
the end. The default values are a space (`’ ‘`) for `sep`
and a newline (`’\n’`) for `end`.

Practice Exercise:
Now that you have a basic understanding of variables,
strings, integers, and the print function, try the following:
1. Create a variable called `course` and assign it the
string value “Python for Web Development”.
2. Create two variables, `students` and `teachers`, and
assign them the integer values 200 and 5, respectively.
3. Use the `print()` function to display the following
message:
“`
Welcome to the course: Python for Web Development.
We have 200 students and 5 teachers.
“`
Remember to use string concatenation and the variables
you’ve created!

Conclusion:
Understanding the basics of variables, strings, and
integers, and how to display them using the `print()`
function is fundamental in Python. This knowledge will
be instrumental as we proceed further into more complex
topics and start our journey with Django. Make sure to
practice the concepts you’ve learned here, as practice is
the key to mastering any programming language.
In the next chapter, we will explore conditional
statements in Python. Stay tuned!

Note: This chapter serves as a brief refresher. If any


topic seems challenging, consider referring to the Python
official documentation or other in-depth Python beginner
courses to gain a deeper understanding.

If Statements and
Comments
Assets and Resources:
- Python 3.x (You can download and install Python from
[python.org]( https://www.python.org/downloads/ ))
- Integrated Development Environment (IDE) like
PyCharm or Visual Studio Code (You can choose any
IDE, but for beginners, I recommend [PyCharm
Community Edition](
https://www.jetbrains.com/pycharm/download/ ))

Introduction
Before diving into web development with Django, it’s
crucial to have a firm grasp on the basic building blocks
of Python. One of the core concepts of any programming
language is conditional statements, with “if statements”
being the most commonly used. In this chapter, we’ll be
exploring if statements, along with Python comments
which play an essential role in making our code
understandable.

If Statements
At its heart, an if statement is a simple decision-making
tool that Python provides. It evaluates an expression
and, based on whether that expression is `True` or
`False`, will execute a block of code.

Basic If Statement
“`python
x = 10
if x > 5:
print(“x is greater than 5”)
“`
In the code above, Python checks if the value of `x` is
greater than 5. If it is, the message “x is greater than 5”
is printed to the console.

If-Else Statement
Often, you’ll want to have an alternative action in case
the if condition isn’t met:
“`python
x=3
if x > 5:
print(“x is greater than 5”)
else:
print(“x is not greater than 5”)
“`

If-Elif-Else Statement
For multiple conditions, Python provides the `elif`
keyword:
“`python
x=5
if x > 10:
print(“x is greater than 10”)
elif x == 5:
print(“x is 5”)
else:
print(“x is less than 10 but not 5”)
“`
In the example above, since `x` is 5, the message “x is
5” will be printed.

Comments in Python
Comments are an essential part of any programming
language. They allow developers to describe what’s
happening in the code, which can be invaluable for both
the original developer and others who might work on the
code in the future.
In Python, the `#` symbol is used to denote a comment.
Any text following this symbol on the same line is
considered a comment and will not be executed by
Python.
“`python
# This is a single-line comment in Python
x = 5 # Assigning value 5 to variable x
“`
For multi-line comments, Python developers often use
triple quotes, though this is technically a multi-line string.
Python simply ignores this string if it’s not assigned to a
variable:
“`python
”’
This is a multi-line
comment in Python
”’
x = 10
“`

Conclusion
If statements form the backbone of decision-making in
Python, allowing us to conditionally execute blocks of
code. Together with comments, which help in clarifying
and explaining our code, these tools are foundational for
any aspiring Python developer.
In the next chapter, we’ll explore functions, another
essential building block in Python.

Func ons
Assets and Resources Required:
1. Python (Version used in this book: Python 3.9) *(You
can download and install Python from the official website
[python.org]( https://www.python.org/downloads/ ).
Ensure you select the version 3.9 or newer during the
setup.)*
2. An IDE or text editor (Recommended: Visual Studio
Code) *(Available for free at [Visual Studio Code’s official
website]( https://code.visualstudio.com/download ).)
3. A working terminal or command prompt to execute
scripts.

Introduction
Functions are a cornerstone of programming in any
language. In Python, functions enable you to bundle a
sequence of statements into a single, reusable entity.
This chapter introduces you to the world of functions,
explaining how to create and use them.
Defining a Function
A function is defined using the `def` keyword, followed by
a name for the function, and then a pair of parentheses.
The code block within every function is indented, which
is a critical aspect of Python syntax.
Here’s a simple function definition:
“`python
def greet():
print(“Hello, World!”)
“`
In the above code, we’ve defined a function named
`greet` that, when called, will print “Hello, World!” to the
console.

Calling a Function
To execute the statements inside a function, you need to
call or invoke the function. To call a function, you simply
use the function name followed by parentheses.
“`python
greet() # This will print “Hello, World!”
“`

Parameters and Arguments


Functions can also accept values, known as parameters,
which allow you to pass data to be processed. When you
define a function and specify parameters, they act like
variables.
Here’s an example:
“`python
def greet(name):
print(f”Hello, {name}!”)
“`
When calling this function, you provide a value, known
as an argument, for the specified parameter:
“`python
greet(“Alice”) # This will print “Hello, Alice!”
“`

Return Values
Functions can also return values using the `return`
keyword. This is useful when you want a function to
evaluate data and give something back.
Here’s an example of a function that takes two numbers,
adds them, and then returns the result:
“`python
def add_numbers(a, b):
result = a + b
return result
sum_result = add_numbers(5, 3)
print(sum_result) # This will print 8
“`

Default Parameter Values


Python allows you to set default values for function
parameters. This means if an argument for that
parameter is omitted when the function is called, the
default value will be used.
“`python
def greet(name=“User”):
print(f”Hello, {name}!”)
greet() # This will print “Hello, User!”
greet(“Bob”) # This will print “Hello, Bob!”
“`

Variable-length Arguments
There might be scenarios where you don’t know the
number of arguments that will be passed into a function.
Python allows you to handle this kind of situation through
*args and kwargs.
“`python
# Using *args
def print_all_args(*args):
for arg in args:
print(arg)
print_all_args(1, “apple”, True, 42.5)
“`

Scope of Variables
In Python, a variable declared inside a function has a
local scope, which means it’s accessible only within that
function. Conversely, variables declared outside all
functions have a global scope.
“`python
global_variable = “I’m global!”
def demo_function():
local_variable = “I’m local!”
print(global_variable) # This is valid
print(local_variable) # This is valid within the
function
print(global_variable) # This will print “I’m global!”
# print(local_variable) # This would result in an error
“`
Summary
In this chapter, we explored the essentials of functions in
Python, which included defining, calling, and returning
values from functions. We also delved into parameter
handling with default values and variable-length
arguments. Grasping the concept of functions and their
flexibility is vital for any budding Python developer. As
you continue in this book, you’ll find that functions play
an integral role in building Django applications.
In the next chapter, we’ll explore Python lists, a crucial
data structure in Python, which will aid us further when
diving into Django’s capabilities.

Lists
Assets and Resources Required for this Chapter:
- Python (version 3.6 or higher) [Can be downloaded and
installed from the official Python website at `
https://www.python.org/downloads/ `]
- A code editor (preferably IDLE, which comes with
Python installation) or any other code editor of your
choice.

Introduction:
Lists are one of the most powerful tools in Python. They
allow you to store multiple items in a single variable.
These items can be of any type, and you can mix types
within a list. This flexibility allows lists to support a
myriad of use cases, from simple collections of numbers
to complex data structures.

Creating a List:
To create a list, use square brackets and separate the
items with commas.
“`python
fruits = [“apple”, “banana”, “cherry”]
print(fruits)
“`
Output:
“`
[‘apple’, ‘banana’, ‘cherry’]
“`

Accessing Items in a List:


To access an item in a list, use its index number. Index
numbers start from 0 for the first item.
“`python
print(fruits[1])
“`
Output:
“`
banana
“`

Modifying Items in a List:


To modify an item in a list, refer to its index number and
assign a new value.
“`python
fruits[1] = “blueberry”
print(fruits)
“`
Output:
“`
[‘apple’, ‘blueberry’, ‘cherry’]
“`

Adding Items to a List:


1. Using the `append()` method: This adds the item to
the end of the list.
“`python
fruits.append(“orange”)
print(fruits)
“`
Output:
“`
[‘apple’, ‘blueberry’, ‘cherry’, ‘orange’]
“`
2. Using the `insert()` method: This adds an item at any
position you choose.
“`python
fruits.insert(1, “kiwi”)
print(fruits)
“`
Output:
“`
[‘apple’, ‘kiwi’, ‘blueberry’, ‘cherry’, ‘orange’]
“`

Removing Items from a List:


1. Using the `remove()` method: This removes the
specified item.
“`python
fruits.remove(“kiwi”)
print(fruits)
“`
Output:
“`
[‘apple’, ‘blueberry’, ‘cherry’, ‘orange’]
“`
2. Using the `pop()` method: Without any argument, it
removes the last item, but you can also specify an index.
“`python
fruits.pop(1)
print(fruits)
“`
Output:
“`
[‘apple’, ‘cherry’, ‘orange’]
“`

Sorting a List:
1. Using the `sort()` method: This sorts the list in
ascending order by default.
“`python
numbers = [34, 1, 98, 23]
numbers.sort()
print(numbers)
“`
Output:
“`
[1, 23, 34, 98]
“`
2. Using the `sorted()` function: This returns a new
sorted list and keeps the original list unchanged.
“`python
sorted_numbers = sorted(numbers, reverse=True)
print(sorted_numbers)
“`
Output:
“`
[98, 34, 23, 1]
“`

List Slicing:
You can return a range of items by specifying a start and
an end index. Remember, the end index is exclusive.
“`python
letters = [‘a’, ‘b’, ‘c’, ‘d’, ‘e’, ‘f’]
print(letters[2:5])
“`
Output:
“`
[‘c’, ‘d’, ‘e’]
“`

List Comprehensions:
This is a concise way to create lists based on existing
lists.
“`python
squared_numbers = [n2 for n in numbers if n > 2]
print(squared_numbers)
“`
Output:
“`
[1156, 529, 9604]
“`

Conclusion:
Lists are one of the foundational data structures in
Python. Their versatility makes them suitable for a range
of applications. By mastering lists, you are taking an
essential step in becoming proficient in Python.
Remember to practice these concepts with various
examples to strengthen your understanding and increase
retention. Happy coding!

Loops
Assets and Resources:
- Python (3.x) - [Can be downloaded from the official
Python website]( https://www.python.org/downloads/ )
- Python Integrated Development Environment (IDE) –
[We recommend the default IDLE or PyCharm for
beginners](
https://www.jetbrains.com/pycharm/download/ )

Introduction:
Loops in programming allow us to execute a block of
code multiple times. Instead of writing the same code
again and again, you can simply loop through it. Python
provides two main types of loops: `for` and `while`. In
this chapter, we’ll explore both types and their practical
applications.

1. The ‘for’ Loop:


In Python, the `for` loop is used to iterate over a
sequence such as a list, tuple, string, or range.
Syntax:
“`python
for variable in sequence:
# code to execute
“`
Example:
Let’s loop through a list of fruits:
“`python
fruits = [“apple”, “banana”, “cherry”]
for fruit in fruits:
print(fruit)
“`
Output:
“`
apple
banana
cherry
“`
2. The ‘range()’ Function with ‘for’ Loop:
When you want to repeat a block of code a specific
number of times, you can use the `range()` function with
a `for` loop.
Syntax:
“`python
for variable in range(start, stop, step):
# code to execute
“`
- `start`: (Optional) The starting value. Default is 0.
- `stop`: The ending value (exclusive).
- `step`: (Optional) The increment value. Default is 1.
Example:
Print numbers from 1 to 5:
“`python
for i in range(1, 6):
print(i)
“`
Output:
“`
1
2
3
4
5
“`

3. The ‘while’ Loop:


A `while` loop continues to execute a block of code as
long as a condition remains true.
Syntax:
“`python
while condition:
# code to execute
“`
Example:
Print numbers from 1 to 5 using a `while` loop:
“`python
count = 1
while count <= 5:
print(count)
count += 1
“`
Output:
“`
1
2
3
4
5
“`

4. ‘break’ and ‘continue’ Statements:


- `break`: Exits the loop prematurely.
- `continue`: Skips the rest of the loop’s current iteration
and moves to the next one.
Example (break):
Find the first number divisible by 7 in a range:
“`python
for num in range(1, 50):
if num % 7 == 0:
print(f”The first number divisible by 7 is {num}.”)
break
“`
Output:
“`
The first number divisible by 7 is 7.
“`
Example (continue):
Print only odd numbers between 1 and 10:
“`python
for num in range(1, 11):
if num % 2 == 0:
continue
print(num)
“`
Output:
“`
1
3
5
7
9
“`

5. Nested Loops:
A loop inside another loop is known as a nested loop. It
can be a combination of `for` and `while` loops.
Example:
Printing a pattern using nested loops:
“`python
for i in range(1, 5):
for j in range(i):
print(“*”, end=”**”)
print()
“`
Output:
“`
*
**
***
****
“`

Conclusion:
Loops play a crucial role in programming, allowing for
repetitive tasks to be handled efficiently. With the
combination of `for` and `while` loops, and the control
offered by `break` and `continue`, Python offers flexibility
and power in managing iterations. Practice is key, so try
to implement these in your Python refresher tasks and
see the magic of loops unfold.

Next, we will dive deeper into Python by exploring one of


its core data structures: Dictionaries. Stay tuned!

Dic onaries
Assets and Resources:
1. Python 3 (Acquire: [Download Python](
https://www.python.org/downloads/ ))
2. A text editor or Integrated Development Environment
(IDE) like PyCharm, Visual Studio Code, or Atom.
3. Terminal (on MacOS/Linux) or Command
Prompt/Powershell (on Windows)

Introduction:
In the Python programming language, a dictionary is a
mutable, unordered collection of items. Every item in the
dictionary has a key/value pair. Dictionaries are used to
store data in a key-value pair format where each key
must be unique. If you come from other programming
languages, you can think of dictionaries as hash maps or
associative arrays.

Creating a Dictionary:
Creating a dictionary is straightforward. You use curly
brackets `{}` to define a dictionary and then specify key-
value pairs. Here’s a simple example:
“`python
person = {
“first_name”: “John”,
“last_name”: “Doe”,
“age”: 30
}
“`
Here, `first_name`, `last_name`, and `age` are keys, and
“John”, “Doe”, and 30 are their respective values.

Accessing Items:
To access the items of a dictionary, you’ll use the key
inside square brackets `[]`:
“`python
print(person[“first_name”]) # Outputs: John
“`
If you try to access a key that doesn’t exist, Python will
raise an error. To prevent this, use the `get()` method:
“`python
print(person.get(“address”, “Not Available”)) # Outputs:
Not Available
“`

Modifying a Dictionary:
You can change the value of a specific item by referring
to its key:
“`python
person[“age”] = 31 # Modifies the age to 31
“`
To add a new key-value pair:
“`python
person[“address”] = “123 Main St” # Adds a new key-
value pair
“`

Removing Items:
Use the `pop()` method to remove an item by its key:
“`python
person.pop(“age”)
“`
Use the `del` statement to remove an item by its key:
“`python
del person[“last_name”]
“`
To clear all items from the dictionary, use the `clear()`
method:
“`python
person.clear()
“`

Iterating Through a Dictionary:


You can loop through a dictionary by using a for loop:
“`python
# Print all keys
for key in person:
print(key)
# Print all values
for key in person:
print(person[key])
# Using the items() method for both keys and values
for key, value in person.items():
print(key, value)
“`

Dictionary Methods:
Python dictionaries offer various methods to make
dictionary manipulations more straightforward:
- `keys()`: Returns a list of dictionary keys.
- `values()`: Returns a list of dictionary values.
- `items()`: Returns a list of dictionary’s key-value tuple
pairs.
- `copy()`: Returns a copy of the dictionary.
- `fromkeys()`: Creates a new dictionary with the
provided keys and values.

Nested Dictionaries:
A dictionary can contain dictionaries, this is called nested
dictionaries.
“`python
family = {
“child1”: {
“name”: “John”,
“year”: 2000
},
“child2”: {
“name”: “Jane”,
“year”: 2003
}
}
“`

Conclusion:
Dictionaries are a fundamental data structure in Python,
and they’re indispensable for any Python programmer.
They provide a clear and intuitive way to store data as
key-value pairs, allowing for efficient data retrieval. With
a good understanding of dictionaries, you’ve now added
a powerful tool to your Python arsenal!
In the next chapter, we’ll explore how to work with
Python classes and learn the basics of object-oriented
programming.

Classes
Assets and Resources:
- Python (Ensure that you have Python installed. If not,
refer to Chapter 1)
- A text editor (Any text editor of your choice, e.g., Visual
Studio Code, PyCharm)

Introduction:
In the realm of programming, a class serves as a
blueprint for creating objects. Objects have member
variables and can perform actions through functions.
Classes are a central part of the object-oriented
programming paradigm that Python supports. Let’s dive
into the concept of classes and understand their
significance and application.

What is a Class?
A class can be visualized as a template or blueprint for
creating objects (instances of the class). These objects
represent data structures composed of attributes (often
called fields or properties) and methods (functions) that
can be applied to the data.
Consider a class as a blueprint for a house. While the
blueprint itself isn’t a house, it dictates how a house
should be built. Similarly, while a class isn’t an instance
of the object, it defines how an object should be created
and behave.

Defining a Class in Python:


Creating a class in Python is simple. Use the `class`
keyword, followed by the class’s name:
“`python
class MyClass:
pass
“`
Here, we’ve defined an empty class named `MyClass`.

Attributes and Methods:


Attributes are the characteristics of a class, whereas
methods represent the actions or behaviors.
Attributes:
Attributes are variables that belong to the class. They
represent data that the class holds.
“`python
class Dog:
species = “Canis familiaris” # This is a class attribute
“`
Methods:
Methods are functions that belong to the class and
define actions.
“`python
class Dog:
species = “Canis familiaris”
def bark(self): # This is a class method
return “Woof!”
“`
The `__init__` Method:
The `__init__` method is a special method in Python,
known as a dunder (double underscore) method. It gets
called automatically when an instance of the class is
created. It’s used to initialize attributes:
“`python
class Dog:
species = “Canis familiaris”
def __init__(self, name, age):
self.name = name
self.age = age
def bark(self):
return f”{self.name} says Woof!”
“`
Here, when you create an instance of the Dog class,
you’ll need to provide a name and age, which will be
assigned to the `self.name` and `self.age` attributes,
respectively.

Creating Instances:
Once the class is defined, you can create instances
(objects) of that class:
“`python
dog1 = Dog(“Buddy”, 5)
dog2 = Dog(“Daisy”, 3)
print(dog1.name) # Output: Buddy
print(dog2.bark()) # Output: Daisy says Woof!
“`

Inheritance:
Inheritance is a mechanism where a new class inherits
attributes and methods from an existing class. The
existing class is called the parent or superclass, and the
new class is the child or subclass.
“`python
class GermanShepherd(Dog):
def guard(self):
return f”{self.name} is guarding!”
gs = GermanShepherd(“Rex”, 4)
print(gs.guard()) # Output: Rex is guarding!
“`
Here, the `GermanShepherd` class inherits from the
`Dog` class, thus inheriting the attributes and methods of
the `Dog` class.

Encapsulation:
In OOP, encapsulation means restricting access to some
of the object’s components, preventing the accidental
modification of data. Python uses underscores to
achieve this:
- `_protected`: With a single underscore, it’s a
convention to treat these as “protected”.
- `__private`: With double underscores, Python name-
mangles the attribute name to make it harder to access.
“`python
class Car:
def __init__(self):
self._speed = 0 # protected attribute
self.__color = “Red” # private attribute
“`
Conclusion:
Understanding classes and OOP concepts in Python
lays a foundational base for the Django framework and
web development in general. With this refresher on
Python classes, you’re now prepared to dive into more
intricate Python-related tasks and tackle Django with
confidence!

Remember, practice is key. The more you experiment


with classes, create different objects, and play around
with attributes and methods, the better you’ll understand
the intricacies and potential of Python’s OOP
capabilities.

Section 2:
Project #1 - Word Counter
Website
Project Intro
Assets & Resources:
1. Django Documentation ([available here](
https://docs.djangoproject.com/en/2.2/ ))
2. Python Software Foundation ([available here](
https://www.python.org/ ))
3. Visual Studio Code or any preferred text editor (You
can download Visual Studio Code [here](
https://code.visualstudio.com/ ))

Introduction
Welcome to the first major section of our journey: Project
#1 - Word Counter Website. This project aims to provide
you with a gentle introduction to the world of Django
while ensuring you grasp the fundamental concepts. It
might seem simple, but the Word Counter Website is
carefully chosen to help you understand the basics of
Django’s flow, URL routing, template rendering, and form
handling.

Overview of the Word Counter Website


Imagine a scenario where you have a long essay,
speech, or document, and you want to know which
words appear the most frequently. Our Word Counter
Website is a tool that will do just that. Users will enter
their text, and the application will display the frequency
of each word in descending order. While this might
sound straightforward, you’ll learn numerous
foundational Django concepts along the way.

What will we build?


Homepage: This is where users will be greeted with a
simple interface where they can paste or type their text.
They will then have the option to submit this text to get
the word count.
Results Page: After submitting the text, users will be
taken to this page where the words and their frequencies
will be displayed.

Why start with the Word Counter Website?


As beginners, it’s essential to start with something that
isn’t overwhelming. The Word Counter Website is perfect
because:
1. Simplicity: The project is straightforward, which means
you won’t get lost in complex logic or multiple
functionalities.
2. Covers the Basics: Despite its simplicity, it introduces
the core elements of a Django application: URL routing,
views, templates, and form handling.
3. Immediate Results: This project will give you the
satisfaction of building a complete web application,
motivating you for the more complex projects ahead.

What will you gain?


By the end of this section, you will:
1. Understand how to set up a new Django project.
2. Familiarize yourself with Django’s directory structure.
3. Handle URL routing and link it with specific views.
4. Design templates to display content to the end-users.
5. Process user input through forms.
6. Learn how to display processed data back to the user.

Pre-requisites
Before diving into the project, ensure you have:
Exploring the Variety of Random
Documents with Different Content
Chapter VI.

NO JUST ANALOGY IN THE PRECEDENTS


ADDUCED BY GOVERNMENT.

A thousand precedents would never justify a bad measure—it may


therefore be deemed superfluous to offer a remark on this head; but
as Mr. Canning has argued, that whatever is adopted in one colony
can safely be introduced into all the rest, and as this maxim has
been taken for granted by many persons willing to save themselves
the trouble of thinking, it is necessary to enter into some explanation.

Section 1.
TRINIDAD.

When the order in council for negro treatment was sent out to
Trinidad, great objections were offered, both generally, and to the
individual clauses which constitute compulsory manumission.
It is not necessary here to inquire how often that order has been
altered, or the reasons why the colonists of Trinidad have been
constrained to submit to the authority imposed upon them. We have
only to show that the case of that island differs from that of the other
British colonies.
Trinidad was originally a Spanish colony; its laws were framed
previously to the abolition of the slave-trade, and have continued
unaltered since the cession of the island to Great Britain.
Now it is apparent that, when fresh slaves can be procured,
compulsory manumission is not so objectionable; because the place
of those who purchase their freedom can be immediately filled up by
others.
It has consequently been considered that, while the slave-trade
was in active operation in the Spanish colonies, the practice of
manumission was encouraged, as increasing the means of
preventing insurrection.
But it is surely unfair to hold up to the imitation of another colony
the enactments and usages introduced by one whose laws were
adapted to a state of things so different; and to require that the
provisions of a code adapted to the existence of the slave-trade,
should be engrafted upon other codes framed since its abolition.
The order in council for Trinidad has not affected the principle of
the Spanish law, or rather the practice in the Spanish colonies, which
allows a slave to enfranchise himself by purchase. But the British law
in our settlements gives no such right whatever to a slave.
According to those codes, the interest of an owner in his slave is
that of a fee-simple absolute: he purchased upon that tenure, he has
continued to hold upon the same, and cannot be deprived of that
legal title without a direct violation of property.
In Trinidad it is otherwise: a person purchasing a slave in that
colony, knows beforehand that he acquires only a precarious title in
such a slave, which depends on the ability of the slave to purchase
himself.
Nor has sufficient time yet elapsed to make known the great
difference in the working of the measure that must take place now
that the slave-trade has ceased, contrasted with the period when it
was in active prosecution.
It ought also to be stated, that the hardship and evils of the law in
Trinidad, even subsequent to the abolition of the slave-trade, had not
been so much felt, from the nature of its laws not being generally
known in this country: consequently, there was no extraneous
excitement upon the subject given to the minds of the negroes.
But now, when this excitement has been given, the brief
experience already afforded, tends strongly to corroborate the
arguments we have advanced; and it is credibly asserted, that the
Secretary for the Colonies has received representations and
appeals, proving evils to have proceeded from the operation of this
law.
Among these evils, theft is shown to have increased; and the
proceedings before the local magistrates are said to evince a
progressive demoralization amongst the negroes.
It is further known, that instances have occurred where the sum
assessed by the appraisers, as the price of manumission, has been
higher than the negro was able, or considered himself entitled, to
pay; and the being sent back under these circumstances has visibly
produced in him a sullenness and discontent exactly as has been
described, and in all probability as injurious to the interests of his
master, as if he had obtained his discharge at his own valuation.
From these circumstances, it is apparent that there is no analogy
between the case of Trinidad and that of the other British Colonies,
and that thus far no proper precedent is established.

Section 2.
ST. LUCIE.

In regard to this colony, the measure has been but recently


introduced, and without the spontaneous concurrence of its
inhabitants. It was established there by the force of arbitrary
authority. There was no adequate court or power, similar in
constitution and functions to the Assemblies in the other islands, to
resist its promulgation; and the threat conveyed in the despatch of
Earl Bathurst to the Governor, thus amounted to an imperative
mandate for the adoption of the measure as law in the colony.
Is this a precedent?

Section 3.
BERBICE.
The case of Berbice is still more flagrant. This colony possessed, a
short time back, a council composed of persons having property at
stake. Before the enactments relating to the slaves in that colony
were brought forward, this council was dismissed, and another
arbitrarily appointed, consisting of persons having no interest in the
cultivation of the colony.
It was previously declared, that the new laws relating to the slaves,
in whatever way they might be finally settled, should not be carried
into operation at Berbice, unless the same measures were at the
same time adopted in Demerara. In the latter colony, all the
measures relating to amelioration were received, and compulsory
manumission alone rejected; but in Berbice, the new council, so
appointed and so composed, passed the latter measure contrary to
the wish of every proprietor in the colony.
It ought moreover to be stated that, before the new laws were
promulgated in Demerara, they were sent home to Lord Bathurst for
confirmation, upon which his Lordship observes,—“The King has
been graciously pleased to approve the decision that you adopted, of
referring the draft of the Act to his Majesty, for his consideration,
instead of immediately promulgating it as a law in the colony.”
But how does the new Council of Berbice act? The most important
of all the new measures they carry at once into effect; that is to say,
they allow no opportunity for parties in England to carry
remonstrance or explanation to the foot of the throne.
Again, let us ask, is this a precedent? What is the meaning of the
term? does it not warrant the inference, in this case, that some
assembly, composed of parties interested, have given their
concurrence? But how marked is the difference between a council
composed of persons possessing little or no property in slaves, and
a court where several of the members hold large plantations, and are
deeply interested in the permanent prosperity of their colony.
The possession of this large stake by the members, and the
circumstance of having delegated interests to represent, peculiarly
conduce to safe and practicable legislation. Such circumstances
present a security against precipitancy,—prompt to a careful and
minute consideration of all local peculiarities,—and procure for every
public measure a full and patient examination of all its relations, both
direct and contingent, before it is permitted to be put in execution.
And further, in respect to any one of these West India cases, has
there elapsed a time sufficient to enable us to estimate the policy of
the experiment, and still less to pronounce upon its fitness for the
whole of our West Indian possessions?

Section 4.
CAPE OF GOOD HOPE.

How this colony should be referred to as a precedent it is difficult to


explain. Its climate differs materially from that of the West Indies. In
the latter, the evils apprehended from giving freedom to the slaves
arise from the impossibility of procuring free labourers to supply their
place. It is but a very short time since emigration from this country to
the Cape of Good Hope was greatly encouraged; and it is
ascertained, by experience, that Europeans can work without injury
or inconvenience in that climate.
Thus the supply of voluntary labourers not only existing, but
increasing in that colony, the inducements to perpetuate slavery
must progressively expire, and slaves may consequently be freed
without injury to the property of their owners, or danger to the public
safety.
From this obvious difference in physical circumstances between
the West India colonies and the Cape of Good Hope, there is no just
analogy between the two; and though compulsory manumission may
be enacted in the one, it cannot, therefore, be taken as a model for
imitation to the other.
This straining after inapplicable precedent clearly indicates
deficiency of argument.
No enactment containing inherently a principle of evil, even though
acceded to willingly, or acquiesced in passively, by individual bodies,
should ever be set up by a wise government as an example for
general adoption.

It has been more than once remarked in Parliament, by persons of


high character, that the precedent generally existing throughout the
Spanish colonies served as a sufficient ground for the measure.
But there are two points which should never be omitted in
reflecting on the question:
I. As to the opportunity of procuring other labourers.
II. The difference of amount sunk in fixed capital, between the
Spanish colonies and those of Great Britain.
In regard to the first, fresh labourers can be procured in the
Spanish colonies, but cannot in the British; and in regard to the
second, there must surely be some difference in the working of a
measure when the amount of capital to be withdrawn varies in the
proportion of 20,000l. in the one case, to a few hundreds in the other.
Chapter VII.

RESPONSIBILITY ATTACHING TO MINISTERS


IF THEY ENFORCE COMPULSORY
MANUMISSION.

Whoever notices the levity of manner with which this question is


treated, would imagine that our constitution had undergone a
change, and that His Majesty’s advisers were relieved from
responsibility for the acts of the executive. On any occasion it is a
rash step to counsel the crown to important measures before a full
investigation has been instituted. But when a step is taken so
contrary to the laws of the realm, as, by eminent law-authorities,
Compulsory Manumission, in regard to mortgaged property, is
conceived to be, responsibility ceases to be an idle term, and
circumstances may arise from it to disturb the peace of a minister of
state much longer than he anticipates.
It can never be too often repeated that, so far as legislation for the
negroes is concerned, what is once done is irrevocable. In other
public measures, an opportunity is afforded to a minister, when he
makes a false step, to change his policy by a dexterous manœuvre.
But no such resource being afforded in the West India Question, we
should conclude that more cautious deliberation would in the first
instance be exercised, and that a full examination would take place
before excitement was created by announcing even the heads of a
new measure. The proceedings hitherto have been on a principle
directly opposite. While the Irish Question remains undecided,
though more than a generation has passed by since it commenced;
and while the Corn Question has stood over until argument on the
subject is exhausted: In the West India Question—where, wrong
measures being once taken, all remedy is hopeless—the parties
whose whole property is at stake cannot be allowed more than the
lapse of a few weeks, to put on record all their objections to the most
essential innovations.
This presents an anomaly in the history of public measures, and it
can only be accounted for by supposing that ministers, amid their
many duties, have completely undervalued the importance of the
measure now pending. This conclusion is confirmed by what is
understood to be their language to independent members of the
legislature whose suffrage they solicit in future discussion. They say
the principal opposition of the West Indians is no more than idle and
transient clamour. It is merely of a piece with what has been always
witnessed. When the abolition of the slave-trade was under
discussion, did we not hear the cry, that our ancient colonies would
be ruined? That great measure was carried, yet no ruin ensued.
When the Registry Bill was brought in, had we not a similar clamour,
that the most dangerous excitement among the slaves would be the
consequence? That point, too, was carried; yet no such direful evils
attended it. Again, when the recent Amelioration Clauses were
proposed, how furious was the opposition in the colonies,—the
proprietors there were to be utterly ruined. Many of these clauses
have since been enacted, even where opposition was strongest at
the first, and yet no injury or change has taken place! What is the
inference in regard to compulsory manumission? We have strenuous
opposition at present, it is true; but when the measure is once
carried, that will soon subside, and all the frightful features of danger
which have alarmed the colonists will turn out to be mere phantoms
of the imagination.
Now, in answer, may we not allege, in the first place, that the
objections urged against those former measures were not
groundless. Our abolition of the slave-trade, without securing the
effectual concurrence of foreign powers in a similar act, has
transferred from British to foreign colonies the principal supply of
Europe with sugar, and without the smallest benefit to Africa. The
Registry Bills are an enormous tax on our impoverished colonies,
and it is not to them we owe the extinction of our colonial slave-
trade. Of our recent Amelioration Clauses, the effect in diminishing
production is as yet more certain than that of increased benefit to the
negro-population.
In the second place, may we not pronounce that the case we are
now submitting is very different from any of those cited?
But in this age of superficiality, where all laborious investigation
seems exploded, and when a well-turned period of declamation in
Parliament sways the nation, let us take another mode of pointing
out the difference of this case.
In those important measures which were passed some time back,
the Government carried a great number of colonial proprietors living
in this country along with them. How different, then, on primâ facie
evidence, must be the nature and bearings of the measure now
proposed, when colonial proprietors, who have always acted with
ministers, are constrained, as a solemn duty in defence of their
properties and of their families, to oppose it strenuously! It is evident,
that to occasion such a feeling, there must be something in the
measure alarmingly important, and demanding the most cautious
scrutiny.
In former times, the letters sent out by colonial proprietors in
England to their friends in the colonies impressed upon the latter, to
do all that they were able, to silence clamour in England; but with
regard to compulsory manumission, the lesser evil is chosen, and
the admonition is, “Beware of passing this measure, and thus
committing yourselves by your own act. Throw all the responsibility
upon ministers, that you may hereafter have full claims for
indemnification.”
The question then resolves itself into this,—Are ministers,
considering the situation in which they are placed, and having a due
regard to their own fame, prepared to take this responsibility upon
themselves? Do they rely upon the passing opinions of the day for
their support? Lord Bathurst says, in his despatches, that the
colonial legislature “may be assured, that from the final
accomplishment of this object this country will not be diverted.”
Now it may be true that, with the unthinking populace, the
extinction of slavery is desired; but what practical statesman would
take this vague expression of feeling for his guide? It may safely be
affirmed, that the intelligent portion of the community are aware of
the difficulties, and expect from Government, not what is theoretically
to be desired, but what is practically and wisely attainable. They are
not prepared to lose our West India colonies, which are believed to
contribute largely to the prosperity and strength of the kingdom; nor
are they at all disposed to inflict injustice upon their fellow-subjects,
knowing well, that whatever odium may now attach to the colonial
proprietor, the charge of having countenanced slavery is one which
he shares with the whole British nation.
But it ought further to be known, and well reflected on by His
Majesty’s ministers, that humane and enlightened individuals, not
anxious for the political so much as the moral grandeur of the
country, who waive every notion of expediency, and consider the
cause of humanity as paramount, are beginning to entertain doubts
as to the wisdom of the proceedings of Government.
This is not vague opinion, but is founded on weighty reasons.
First: That it is the object of British humanity to exalt the entire
African race, and to accomplish it as a matter of genuine
philanthropy in the most general and efficient manner.
It appears by parliamentary documents, that as cultivation, during
some years past, has decreased in the British colonies, precisely in
the same degree has the slave-trade of foreigners increased.
To ruin or deteriorate the British colonies is thus to encourage the
horrors of the slave-trade, and to increase the sum of African
suffering.
Therefore, it being the object of the British nation to abridge that
suffering, and not to make a mere display of sensibility, if the
proposed measures can be proved to be destructive of cultivation in
the British colonies, their spirit must be pronounced to be contrary to
the sentiments of the country.
And, Secondly: That having long since committed the crime of
transporting the negroes to our West India colonies, it is expected by
the British nation, that the welfare of future generations will be
contemplated; and that, hereafter, a black society may be witnessed,
possessing in itself the attributes, moral, intellectual, and political, of
a civilized people.
So strongly does this sentiment pervade the nation, that it is
common to hear the inquiry—“What are the negroes to do when
free?” implying the belief that rash interference may have proceeded
far to accomplish the object, but that judicious legislation has
stopped short on the threshold.
If we were to make an appeal to Lord Bathurst, and to all who
have taken an active part in the promotion of compulsory
manumission, must they not acknowledge, that since the agitation of
the subject in 1823, a considerable and perceptible change has
taken place in public opinion, in consequence of the inquiry relative
to free labour; and that the idea of having a free negro-peasantry
labouring under a tropical climate for hire is impracticable and
hopeless.
Does not, then, the whole question depend on free labour?
We cannot but infer, that when the relations and consequences of
granting freedom to the negroes by compulsion are fully understood
in all their widely-spreading effects, the opinion of the country will be
as strongly expressed in reprobation, as Earl Bathurst pronounces it
at present to be in approbation of the speedy adoption of the
measure.
Without any disrespect it may be stated, that some of our
ministers, who are upborne by the current of public applause, have
had sufficient experience of the fickleness of popularity. Let us recall
to mind the wise precept of Mr. Canning in 1819—“Speak not the will
of the populace, but consult their benefit.”
We appeal to each member of parliament to further this counsel.
The question of negro-emancipation is virtually before them. It is
conceived, by all those whose properties are at stake, to be
presented in its most objectionable form, and they unanimously
oppose it. Before deciding on the subject, let every member reflect
on the sentiments of two of our greatest statesmen.
Mr. Pitt, in every discussion in which negro-emancipation was
agitated, pronounced, that it was an act which must “flow from the
master alone.”
When that presiding genius of the country’s commercial greatness
was no more—when Mr. Fox had coalesced with Lord Grenville,—
and above all, when the whole anti-colonial party, with Mr.
Wilberforce at its head, had joined his ranks, Mr. Fox, in the full tide
of his popularity and his power, declared—
“That the idea of an act of parliament to emancipate the slaves in
the West Indies, without the consent and concurrent feeling of all
parties concerned, both in this country and in that, would not
only be mischievous in its consequences, but totally extravagant in
its conception, as well as impracticable in its execution.”

THE END.
LONDON:

PRINTED BY W. CLOWES,

Stamford-street.
TRANSCRIBER’S NOTE
Obvious typographical and punctuation errors have been corrected after
careful comparison with other occurrences within the text and consultation of
external sources.
Some hyphens in words have been silently removed (e.g., “West India” and
“West Indian”) and added (e.g., “sugar-plantation” and “sugar-estate”), when a
predominant preference was found in the original book.
Except for those changes noted below, all misspellings and inconsistent or
archaic usage in the text have been retained.
Page 3: “particular acts ema nate” replaced by “particular acts emanate”
Page 63: “announce to theslaves” replaced by “announce to the slaves”
*** END OF THE PROJECT GUTENBERG EBOOK COMPULSORY
MANUMISSION ***

Updated editions will replace the previous one—the old editions will
be renamed.

Creating the works from print editions not protected by U.S.


copyright law means that no one owns a United States copyright in
these works, so the Foundation (and you!) can copy and distribute it
in the United States without permission and without paying copyright
royalties. Special rules, set forth in the General Terms of Use part of
this license, apply to copying and distributing Project Gutenberg™
electronic works to protect the PROJECT GUTENBERG™ concept
and trademark. Project Gutenberg is a registered trademark, and
may not be used if you charge for an eBook, except by following the
terms of the trademark license, including paying royalties for use of
the Project Gutenberg trademark. If you do not charge anything for
copies of this eBook, complying with the trademark license is very
easy. You may use this eBook for nearly any purpose such as
creation of derivative works, reports, performances and research.
Project Gutenberg eBooks may be modified and printed and given
away—you may do practically ANYTHING in the United States with
eBooks not protected by U.S. copyright law. Redistribution is subject
to the trademark license, especially commercial redistribution.

START: FULL LICENSE


THE FULL PROJECT GUTENBERG LICENSE
PLEASE READ THIS BEFORE YOU DISTRIBUTE OR USE THIS WORK

To protect the Project Gutenberg™ mission of promoting the free


distribution of electronic works, by using or distributing this work (or
any other work associated in any way with the phrase “Project
Gutenberg”), you agree to comply with all the terms of the Full
Project Gutenberg™ License available with this file or online at
www.gutenberg.org/license.

Section 1. General Terms of Use and


Redistributing Project Gutenberg™
electronic works
1.A. By reading or using any part of this Project Gutenberg™
electronic work, you indicate that you have read, understand, agree
to and accept all the terms of this license and intellectual property
(trademark/copyright) agreement. If you do not agree to abide by all
the terms of this agreement, you must cease using and return or
destroy all copies of Project Gutenberg™ electronic works in your
possession. If you paid a fee for obtaining a copy of or access to a
Project Gutenberg™ electronic work and you do not agree to be
bound by the terms of this agreement, you may obtain a refund from
the person or entity to whom you paid the fee as set forth in
paragraph 1.E.8.

1.B. “Project Gutenberg” is a registered trademark. It may only be


used on or associated in any way with an electronic work by people
who agree to be bound by the terms of this agreement. There are a
few things that you can do with most Project Gutenberg™ electronic
works even without complying with the full terms of this agreement.
See paragraph 1.C below. There are a lot of things you can do with
Project Gutenberg™ electronic works if you follow the terms of this
agreement and help preserve free future access to Project
Gutenberg™ electronic works. See paragraph 1.E below.
1.C. The Project Gutenberg Literary Archive Foundation (“the
Foundation” or PGLAF), owns a compilation copyright in the
collection of Project Gutenberg™ electronic works. Nearly all the
individual works in the collection are in the public domain in the
United States. If an individual work is unprotected by copyright law in
the United States and you are located in the United States, we do
not claim a right to prevent you from copying, distributing,
performing, displaying or creating derivative works based on the
work as long as all references to Project Gutenberg are removed. Of
course, we hope that you will support the Project Gutenberg™
mission of promoting free access to electronic works by freely
sharing Project Gutenberg™ works in compliance with the terms of
this agreement for keeping the Project Gutenberg™ name
associated with the work. You can easily comply with the terms of
this agreement by keeping this work in the same format with its
attached full Project Gutenberg™ License when you share it without
charge with others.

1.D. The copyright laws of the place where you are located also
govern what you can do with this work. Copyright laws in most
countries are in a constant state of change. If you are outside the
United States, check the laws of your country in addition to the terms
of this agreement before downloading, copying, displaying,
performing, distributing or creating derivative works based on this
work or any other Project Gutenberg™ work. The Foundation makes
no representations concerning the copyright status of any work in
any country other than the United States.

1.E. Unless you have removed all references to Project Gutenberg:

1.E.1. The following sentence, with active links to, or other


immediate access to, the full Project Gutenberg™ License must
appear prominently whenever any copy of a Project Gutenberg™
work (any work on which the phrase “Project Gutenberg” appears, or
with which the phrase “Project Gutenberg” is associated) is
accessed, displayed, performed, viewed, copied or distributed:
This eBook is for the use of anyone anywhere in the United
States and most other parts of the world at no cost and with
almost no restrictions whatsoever. You may copy it, give it away
or re-use it under the terms of the Project Gutenberg License
included with this eBook or online at www.gutenberg.org. If you
are not located in the United States, you will have to check the
laws of the country where you are located before using this
eBook.

1.E.2. If an individual Project Gutenberg™ electronic work is derived


from texts not protected by U.S. copyright law (does not contain a
notice indicating that it is posted with permission of the copyright
holder), the work can be copied and distributed to anyone in the
United States without paying any fees or charges. If you are
redistributing or providing access to a work with the phrase “Project
Gutenberg” associated with or appearing on the work, you must
comply either with the requirements of paragraphs 1.E.1 through
1.E.7 or obtain permission for the use of the work and the Project
Gutenberg™ trademark as set forth in paragraphs 1.E.8 or 1.E.9.

1.E.3. If an individual Project Gutenberg™ electronic work is posted


with the permission of the copyright holder, your use and distribution
must comply with both paragraphs 1.E.1 through 1.E.7 and any
additional terms imposed by the copyright holder. Additional terms
will be linked to the Project Gutenberg™ License for all works posted
with the permission of the copyright holder found at the beginning of
this work.

1.E.4. Do not unlink or detach or remove the full Project


Gutenberg™ License terms from this work, or any files containing a
part of this work or any other work associated with Project
Gutenberg™.

1.E.5. Do not copy, display, perform, distribute or redistribute this


electronic work, or any part of this electronic work, without
prominently displaying the sentence set forth in paragraph 1.E.1 with
active links or immediate access to the full terms of the Project
Gutenberg™ License.
1.E.6. You may convert to and distribute this work in any binary,
compressed, marked up, nonproprietary or proprietary form,
including any word processing or hypertext form. However, if you
provide access to or distribute copies of a Project Gutenberg™ work
in a format other than “Plain Vanilla ASCII” or other format used in
the official version posted on the official Project Gutenberg™ website
(www.gutenberg.org), you must, at no additional cost, fee or expense
to the user, provide a copy, a means of exporting a copy, or a means
of obtaining a copy upon request, of the work in its original “Plain
Vanilla ASCII” or other form. Any alternate format must include the
full Project Gutenberg™ License as specified in paragraph 1.E.1.

1.E.7. Do not charge a fee for access to, viewing, displaying,


performing, copying or distributing any Project Gutenberg™ works
unless you comply with paragraph 1.E.8 or 1.E.9.

1.E.8. You may charge a reasonable fee for copies of or providing


access to or distributing Project Gutenberg™ electronic works
provided that:

• You pay a royalty fee of 20% of the gross profits you derive from
the use of Project Gutenberg™ works calculated using the
method you already use to calculate your applicable taxes. The
fee is owed to the owner of the Project Gutenberg™ trademark,
but he has agreed to donate royalties under this paragraph to
the Project Gutenberg Literary Archive Foundation. Royalty
payments must be paid within 60 days following each date on
which you prepare (or are legally required to prepare) your
periodic tax returns. Royalty payments should be clearly marked
as such and sent to the Project Gutenberg Literary Archive
Foundation at the address specified in Section 4, “Information
about donations to the Project Gutenberg Literary Archive
Foundation.”

• You provide a full refund of any money paid by a user who


notifies you in writing (or by e-mail) within 30 days of receipt that
s/he does not agree to the terms of the full Project Gutenberg™
License. You must require such a user to return or destroy all
Welcome to our website – the ideal destination for book lovers and
knowledge seekers. With a mission to inspire endlessly, we offer a
vast collection of books, ranging from classic literary works to
specialized publications, self-development books, and children's
literature. Each book is a new journey of discovery, expanding
knowledge and enriching the soul of the reade

Our website is not just a platform for buying books, but a bridge
connecting readers to the timeless values of culture and wisdom. With
an elegant, user-friendly interface and an intelligent search system,
we are committed to providing a quick and convenient shopping
experience. Additionally, our special promotions and home delivery
services ensure that you save time and fully enjoy the joy of reading.

Let us accompany you on the journey of exploring knowledge and


personal growth!

ebookmass.com

You might also like