Python Descriptors: Understanding and Using the Descriptor Protocol 1st Edition Jacob Zimmerman - The full ebook with all chapters is available for download now
Python Descriptors: Understanding and Using the Descriptor Protocol 1st Edition Jacob Zimmerman - The full ebook with all chapters is available for download now
com
https://textbookfull.com/product/python-descriptors-
understanding-and-using-the-descriptor-protocol-1st-edition-
jacob-zimmerman/
OR CLICK HERE
DOWLOAD EBOOK
https://textbookfull.com/product/python-descriptors-1st-edition-jacob-
zimmerman/
textbookfull.com
https://textbookfull.com/product/using-asyncio-in-python-
understanding-python-s-asynchronous-programming-features-caleb-
hattingh/
textbookfull.com
https://textbookfull.com/product/introduction-to-computation-and-
programming-using-python-with-application-to-understanding-data-
guttag/
textbookfull.com
https://textbookfull.com/product/supervised-learning-with-python-
concepts-and-practical-implementation-using-python-1st-edition-
vaibhav-verdhan/
textbookfull.com
https://textbookfull.com/product/supervised-learning-with-python-
concepts-and-practical-implementation-using-python-vaibhav-verdhan/
textbookfull.com
https://textbookfull.com/product/chemical-and-biomedical-engineering-
calculations-using-python-1st-edition-jeffrey-j-heys/
textbookfull.com
https://textbookfull.com/product/computational-nuclear-engineering-
and-radiological-science-using-python-1st-edition-ryan-mcclarren/
textbookfull.com
https://textbookfull.com/product/introduction-to-computing-and-
problem-solving-using-python-1st-edition-e-balaguruswamy/
textbookfull.com
Python
Descriptors
Understanding and Using the
Descriptor Protocol
—
Second Edition
—
Jacob Zimmerman
Python Descriptors
Understanding and Using
the Descriptor Protocol
Second Edition
Jacob Zimmerman
Python Descriptors: Understanding and Using the Descriptor Protocol
Jacob Zimmerman
New York, USA
iii
Table of Contents
iv
Table of Contents
Chapter 9: Writing__delete__()�����������������������������������������������������������67
Summary������������������������������������������������������������������������������������������������������������68
v
Table of Contents
Bibliography���������������������������������������������������������������������������������������93
Index���������������������������������������������������������������������������������������������������95
vi
About the Author
Jacob Zimmerman is a blogger, gamer (tabletop more so than video
games), and programmer who was born and raised in Wisconsin. He has a
twin brother who could also be considered to have all those traits.
Jacob has his own programming blog that focuses on Java, Kotlin,
and Python programming, called “Programming Ideas with Jake”. He also
writes for a gaming blog with his brother-in-law called the “Ramblings of
Jacob and Delos”.
His brother writes a JavaScript blog called JoeZimJS and works with
his best friend on a gaming YouTube channel called “Bork & Zim Gaming,”
which Jacob helps out with on occasion.
Programming Ideas with Jake
http://programmingideaswithjake.wordpress.com/
Ramblings of Jacob and Delos
http://www.ramblingsofjacobanddelos.com/
JoeZimJS
http://www.joezimjs.com
vii
About the Technical Reviewer
Michael Thomas has worked in software development for more than 20
years as an individual contributor, team lead, program manager, and vice
president of engineering. Michael has more than 10 years of experience
working with mobile devices. His current focus is in the medical sector,
using mobile devices to accelerate information transfer between patients
and health care providers.
ix
Acknowledgments
In order to be sure that I got everything right—it would really suck for a
“comprehensive guide” to be missing a big chunk of functionality or to get
anything wrong—I enlisted the help of some Python experts on the first
edition. In return for their help, I let them introduce themselves to you
here. That’s not all I did in return, but it’s all you’re going to see :)
Emanuel Barry is a self-taught Python programmer who loves pushing
the language to its limits as well as exploring its darkest corners. He has to
do a lot of proofreading and editing for a local non-for-profit organization,
and decided to combine his love of Python and knowledge sharing with
his background in proofreading to help make this book even better. He can
often be found in the shadows of the mailing lists or the issue tracker, as
well as the Python IRC channel, as Vgr.
Chris Angelico has played around with Python since the late 90s, getting
more serious with the language in the mid 2000s. As a PEP Editor and active
participant in the various mailing lists, he keeps well up to date with what’s
new and upcoming in the language and also shares that knowledge with
fledgling students in the Thinkful tutoring/mentoring program. When not
coding in Python, he is often found wordsmithing for a Dungeons & Dragons
campaign, or exploring the linguistic delights of Alice in Wonderland and
similar works. If you find a subtle Alice reference in this text, blame him!
https://github.com/Rosuav
xi
Introduction
Python is a remarkable language with many surprisingly powerful features
baked into it. Generators, metaclasses, and decorators are some of those,
but this book is all about descriptors.
Code Samples
All code samples are written in Python 3, since that is the most recent
version, but all the ideas and principles taught in this book apply to Python
2 as well, as long as you’re using new style classes.
Note Superscript letters like the one at the end of the previous line
are in reference to the bibliography at the back of the book, which
includes URLs to the referenced site.
xiii
Introduction
xiv
PART I
About Descriptors
Part I is a deep explanation of what descriptors are, how they work, and
how they’re used. It gives enough information that you should be able to
look at any descriptor and understand how it works and why it works that
way, assuming the writer of the code made the code legible enough.
Creating your own descriptors isn’t difficult once you have the
information from Part I, but little to no guidance is given to help with
it. Instead, Part II covers that with a bunch of options for creating new
descriptors, as well as tips for avoiding common mistakes.
CHAPTER 1
What Is a Descriptor?
Put very simply, a descriptor is a class that can be used to call a method
with simple attribute access, but there’s obviously more to it than that. It’s
difficult to explain beyond that without digging a little into how descriptors
implemented. So, here’s a high-level view of the descriptor protocol.
A descriptor implements at least one of these three methods:
__get__(), __set__(), or __delete__(). Each of those methods has a list
of parameters needed, which will be discussed a little later, and each is
called by a different sort of access of the attribute the descriptor represents.
Doing simple a.x access will call the __get__() method of x; setting the
attribute using a.x = value will call the __set__() method of x; and using
del a.x will call, as expected, the __delete__() method of x.
4
Chapter 1 What Is a Descriptor?
Summary
As you have seen, descriptors occupy a large part of the Python language, as
they can replace attribute access with method calls, and even restrict which
types of attribute access is allowed. Now that you have a broad idea of how
descriptors are implemented as well as their use by the language, we will
dig a little deeper yet, gaining a better understanding of how they work.
5
CHAPTER 2
The Descriptor
Protocol
In order to get a better idea of what descriptors are good for, let’s finish
showing the full descriptor protocol. It’s time to see the full signatures of
the protocol’s methods and what the parameters are.
that it’s being called from the class level. But, if instance is not None, then it
tells the descriptor which instance it’s being called from. So an a.x call will
be effectively translated to type(a).__dict__['x'].__get__(a, type(a)).
Notice that it still receives the instance’s class. Notice also that the call still
starts with type(a), not just a, because descriptors are stored on classes.
In order to be able to apply per-instance as well as per-class functionality,
descriptors are given instance and owner (the class of the instance). How
this translation and application happens will be discussed later.
Remember—and this applies to __set__() and __delete__() as
well—self is an instance of the descriptor itself. It is not the instance that
the descriptor is being called from; the instance parameter is the instance
the descriptor is being called from. This may sound confusing at first, but
don’t worry if you don’t understand for now—everything will be explained
further.
The __get__() method is the only one that bothers to get the class
separately. That’s because it’s the only method on non-data descriptors,
which are generally made at a class level. The built-in decorator
classmethod is implemented using descriptors and the __get__()
method. In that case, it will use the owner parameter alone.
8
Chapter 2 The Descriptor Protocol
The last parameter is value, which is the value the attribute is being
assigned.
One thing to note: when setting an attribute that is currently a
descriptor from the class level, it will replace the descriptor with whatever
is being set. For example, A.x = someValue does not get translated to
anything; someValue replaces the descriptor object stored in x. To act on
the class, see the following note.
9
Chapter 2 The Descriptor Protocol
Summary
That’s the sum total of the descriptor protocol. Having a basic idea of how
it works, you’ll now get a high-level view of the types of things that can be
done with descriptors.
10
CHAPTER 3
E ncapsulation
One of the most useful aspects of descriptors is that they encapsulate
data so well. With descriptors, you can access an attribute the simple way
using attribute access notation (a.x) while having more complex actions
happen in the background. For example, a Circle class might have radius,
diameter, circumference, and area all available as if they were attributes,
but since they’re all linked, you only need to store one (we’ll use the radius
for the example) and calculate the others based on it. But from the outside,
they all look like attributes stored on the object.
Lazy Instantiation
You can use descriptors to define a really simple syntax for lazily
instantiating an attribute. There will be code provided for a nice lazy
attribute implementation later in the book.
In the Circle example, the non-radius attributes, after having their
caches invalidated, don’t need to calculate their values right away; they
could wait until they’re needed. That’s laziness.
Validation
Many descriptors are written simply to make sure that data being passed
in conforms to the class’ or attribute’s invariants. Such descriptors can
usually be designed as handy decorators, too.
Again with the Circle example: all of those attributes should be
positive, so all the descriptors could also make sure the value being set is
positive.
Triggering Actions
Descriptors can be used to trigger certain actions when the attribute is
accessed. For example, the observer pattern can be implemented in a
per-attribute sense to trigger calls to the observer whenever an attribute is
changed.
12
Chapter 3 What Are Descriptors Good For?
Last Circle example: all the “attributes” are based on the radius
calculated lazily. In order to keep from having to calculate them every
time, you could cache the result. Then, whenever one of them changes,
it could trigger invalidating all the others’ caches.
Encapsulation
Wait… encapsulation was a pro. How can it also be a con? The problem
is that you can hide incredible amounts of complexity behind something
that just looks like attribute use. With getters and setters, the user at least
sees that there’s a function being called, and plenty can happen in a single
function call. But the user won’t necessarily expect that what is seemingly
attribute access is causing something else to happen, too. Most of the time,
this isn’t a problem, but it can get in the user’s way of trying to debug any
problems, since clearly that code can’t be a problem.
13
Chapter 3 What Are Descriptors Good For?
Additional Objects
Because descriptors add another layer of indirection/abstraction to the
mix, they also add at least one additional object in memory, along with at
least one additional call stack level. In most cases, it’ll be more than one of
each. This adds bloat that could at least be partially mitigated using getters
and setters.
Summary
Descriptors are awesome, allowing for a variety of nice features that are
good at hiding their complexity from users of your code, but you should
definitely be aware that the power comes with cost.
14
CHAPTER 4
Descriptors in the
Standard Library
There are three basic, well-known descriptors that come with Python:
property, classmethod, and staticmethod. There’s also a fourth one that
you use all the time, but are less likely to know is a descriptor.
Of all the descriptors being shown in this chapter, it’s possible that
you only knew of property as a descriptor. Plenty of people even learn
the basics of descriptors from it, but a lot of people don’t know that
classmethod and staticmethod are descriptors. They feel like super
magical constructs built into the language that no one could reproduce in
pure Python. Once someone has an understanding of descriptors, though,
their basic implementation becomes relatively obvious. In fact, example
code will be provided for all three in simplified, pure Python code.
Lastly, it will be shown that all methods are actually implemented
with descriptors. Normal methods are actually done “magically,” since the
descriptor creation is implicit, but it’s still not entirely magical because it’s
done using a language construct the anyone could create.
What I find really interesting is that the first three are all function
decorators, which are another really awesome feature of Python that
deserves its own book, even though they’re way simpler.
class property:
def __init__(self, fget=None, fset=None, fdel=None):
self.fget = fget
self.fset = fset
self.fdel = fdel
16
Chapter 4 Descriptors in the Standard Library
As you can now see, the property class has almost no real functionality
of its own; it simply delegates to the functions given to it. When a function
is not provided for a certain method to delegate to, property assumes that
it is a forbidden action and raises an AttributeError with an appropriate
message.
A nice thing about the property class is that it largely just accepts
methods. Even its constructor, which can be given all three methods at
once, is capable of being called with just one, or even none. Because of
this, the constructor and other methods can be used as decorators in a
very convenient syntax. Check out the documentation2 to learn more
about it.
Omitted from this code example is the doc functionality, where it sets
its own __doc__ property based on what is passed in through __init__()’s
doc parameter or using __doc__ from fget if nothing is given. Also omitted
is the code that sets other attributes on property, such as __name__, in
order to help it appear even more like a simple attribute. They did not
seem important enough to worry about, since the focus was more on the
main functionality.
17
Chapter 4 Descriptors in the Standard Library
class classmethod:
def __init__(self, func):
self.func = func
18
Chapter 4 Descriptors in the Standard Library
class staticmethod:
def __init__(self, func):
self.func = func
Regular Methods
Remember that it was stated earlier that regular methods implicitly use
descriptors as well. In fact, all functions can be used as methods. This is
because functions are non-data descriptors as well as callables.
Here is a Python implementation that roughly shows how a function
looks.
class function:
def __call__(self, *args, **kwargs):
# do something
19
Other documents randomly have
different content
In the broader valleys, where the streams are smaller, or have done
less destruction to the country, grows the giant diàdia grass, the stems
often attaining two and a half inches in circumference and a mean
height of fifteen feet; there may be found some of the richest soil in
the world. Where the diàdia has been exists the wildest luxuriance of
vegetation; palms, plantain, Indian corn, ground-nuts, yams and all
garden produce are at their best, and ever at the mercy of the
elephants, who rejoice in such choice selection. In the Majinga country
the native houses have to be scattered through their rich farms, and
morning and night the people shout, scream, and beat their drums to
frighten off these giant marauders.
It is not a forest country. Strange clumps of trees grow on the tops
of the hills, which mark the ancient plateau level, but the rich soil
beside the streams and in the snug valleys is generally well wooded.
The vegetation presents an altogether tropical appearance, the bracken
in the glades is the only thing home-like. Rich creepers drape the trees,
beautiful palms lend their rare grace, and in their seasons an endless
succession of beautiful flowers, from huge arums to a tiny crucifer of
the richest scarlet, bright creepers, pure white stephanotis-like
blossoms, rich lilies, and many other gorgeous plants, and bright
berries, not in such wild, packed profusion that the eye is bewildered
with a blaze of beauty, but here and there with sufficient interval to
permit the due appreciation of their several lovelinesses. The beauty of
the leaf-forms is alone a pleasure; while the tints from the darkest
green to soft yellow, delicate pink, bronze, chocolate, and bright
crimson are mysteries of colour. On the rocky stream banks and on the
palm stems are graceful ferns, while the lycopodium climbs the bushes,
mingled with the beautiful selaginella. The scenery of the country is
described in an unequalled manner by Mr. H. H. Johnston in his book,
The River Congo. Himself an accomplished artist, he describes as only
an artist can.
The vegetation suffers from the annual grass fires, which sweep
the country. As soon as the dry season has well set in (June) the
burning commences; in some parts it does not become general until
August. The grass is fired sometimes on a small scale by the children,
that they may hunt their rats, but the great fires occur when the
natives of a district combine for a grand hunt. For days the fire steadily
sweeps along, the game flee before it, hawks wheel above the line of
fire, catching the grasshoppers that seek to avoid the flames, while
smaller birds catch the lesser insects. The internodes of the burning
grass explode with a report like that of a pistol, and can be heard
distinctly a mile distant. Women and children follow on the line to dig
out the rats; and in the holes may be found rats, mice, snakes, and
lizards, seeking common protection from a common danger. At night
the horizon is lit up by the zigzag lines of fire, and in the daytime are
seen the thick columns of smoke slowly advancing, and filling the air
with a dull haze, which limits the horizon to ten or fifteen miles.
The climate of the Congo has been unduly vilified. In common with
all intertropical regions there is a malarial fever, which has claimed
many victims. It generally assumes an intermittent type, commencing
with an ague ‘shake;’ sometimes it is remittent, and combines with
grave symptoms. Although the precise nature of the malarial germ is
still unknown, continued study has enabled medical men to grapple
much more successfully with this great enemy. So long as it was the
custom to treat the fever with bleeding and calomel it was no wonder
that Africa was ‘the white man’s grave;’ that was not so much the fault
of Africa as the white man’s ignorance.
Traders on the coast have generally fair health, and many live to
old age. Ladies in the Mission stations and elsewhere live long on the
coast. Indeed, Dr. Laws, of Livingstonia, has expressed an opinion that
ladies, as a rule, stand the climate better than the men.
In these matters we are far readier to count up the misfortunes
than to note the large proportion of those who live long and do good
work in Africa.
New missions and scientific expeditions have paid the penalty for
ignorance and the difficulties of pioneering; but where the experience
of others can aid, and due precautions are observed, there is no reason
why the Congo should be considered more unhealthy than India
generally. It is certainly possible to live on the Congo. The writer, who
was one of the first party of the Baptist Missionary Society’s Congo
Mission, and has had five years’ pioneering work, had not a single fever
during the last two and a half years. This is rather exceptional, but
speaks well as to the possibilities. Indeed, there are many reasons why
the climate of India should be considered worse. The Indian
temperature is far higher, dysentery and cholera are annual scourges,
and liver complaints far more common.
The excellent Observations Météorologiques of Dr. A. von
Danckelman, of the International Association (Asher and Co., Berlin),
gives most interesting statistics of the Lower Congo. The highest
temperature registered by him at an elevation of 375 feet was 96·5°
Fahr., and the lowest 53°, the highest mean temperature being 83°.
The general midday temperature in the house in the hot season is
80°-85°; and at night 75°-80°. On the coast a cool breeze blows in
from the sea from about eleven o’clock in the morning; commencing
somewhat later in proportion to the distance in the interior. This same
cool sea-breeze blows freshly on the upper river, and even when high
temperatures can be taken in the sun the air is cool. Very frequently
thick clouds cover the sky and temper the heat. In this respect the
Congo compares very favourably with India, and with other parts of the
African coast. On the Congo a punkah is quite unnecessary at any time,
in a house built on a reasonable site.
The rainy season commences in the cataract region about
September 15, attaining the maxima in November and April, with a
minimum (the ‘little rains’) about Christmas time, and ceasing about
May 15. The rise of the river commences about August, for the
northern rains, culminating about January 1, when it falls rapidly until
April 1. It then rises rapidly to a second but lower maximum about May
1; it then steadily falls until August. These dates may vary a fortnight,
or even three weeks; that is to say, they may occur so much earlier, but
seldom later.
The rain generally falls at night, often with a violent tornado soon
after sundown. Heavy clouds appear on the horizon, the tornado arch
advances, the wind lulls, and with breathless suspense everything
prepares for the onslaught of the storm. A dull roar is heard. The hiss
of coming rain, fierce gusts of wind, and in a moment the deluge is
upon you. Wild wind, torrents of rain, incessant peals of thunder,
flashes of lightning every few seconds. The whole world seems to be
going to rack and ruin. After an hour or two the fury of the storm is
spent, and heavy rain continues for a while.
Considering the intensity of the electric disturbance, accidents by
lightning are rare. One or two cases only have been noted thus far: the
mission boat on the Cameroons River was struck, and three people on
board killed; a house of the International Association was fired; the
same thing occurred in a native village. Occasionally a tree is struck.
* * * * *
The inhabitants of Africa have been divided into six great races.
Their languages form the basis of such division. Mr. R. N. Cust, the
Secretary of the Royal Asiatic Society, has recently published a valuable
work on the Languages of Africa, and the coloured map accompanying
it presents the distribution of races very graphically to the eye. To the
north we find the Semitic race. In the Sahara, on the Nile, in Abyssinia
and in Somali land, a Hamitic race, speaking languages allied to
Ethiopic. From Gambia to the mouths of the Niger the Negro race, of
whom the Ashantees are types.
Interspersed among the Negro and Hamitic races are detached
peoples, speaking languages of the Nuba Fullah group, of whom the
Masai, among whom Mr. Thomson has been travelling, to the east of
the Victoria Nyanza, may be taken as types.
To the south of all these is the great Bantu (= men) race. A line
drawn eastward from the Gulf of Biafra to the Indian Ocean will mark
roughly the boundary of this greatest of the African races. Near to the
Cape of Good Hope are found the Hottentot Bushman, a degraded
race, who appear to have been the aborigines, but now driven to the
remotest corner, are still yielding to the stronger Bantus.
It is surmised that some dwarf races, said to be scattered through
the Bantu countries, may be of this aboriginal stock, but no satisfactory
opportunities have yet offered for ascertaining the truth. These dwarfs
are always a little beyond the countries visited by travellers, a few
specimens, said to belong to them, have been seen, but their country is
ever elusive. It is likely that they may prove to be degraded tribes of
the races among whom they dwell, just as the Niam Niams are believed
to be Nuba-Fullahs.
Of the Bantus the Zulu Kaffirs may be the best known types,
although they have borrowed from the Hottentots the clicks that so
much disfigure their language.
With the exception of these hypothetical dwarfs, the inhabitants of
the Congo basin are all Bantus.
As before stated, language is the basis of such classification. With
the other races they have nothing in common. In roots, grammatical
construction and all distinguishing features of language, the Bantu
dialects have a marked individuality, differing almost totally from the
other races, while showing the most marked affinities among
themselves. It would be inappropriate to burden the present paper with
a lengthy dissertation on the peculiarities of the Bantu languages. The
most marked feature is the euphonic concord, a principle by which the
characteristic prefix of the noun is attached to the pronouns and
adjectives, qualifying it, and to the verb of which it is the subject. Thus
matadi mama mampwena mampembe mejitanga beni: these great
white stones are very heavy. Quoting J. R. Wilson, Mr. Cust remarks
that ‘The Bantu languages are soft, pliant, and flexible, to an almost
unlimited extent. Their grammatical principles are founded on the most
systematic and philosophical basis, and the number of words may be
multiplied to an almost indefinite extent. They are capable of
expressing all the nicer shades of thought and feeling, and perhaps no
other languages of the world are capable of more definiteness and
precision of expression. Livingstone justly remarks that a complaint of
the poverty of the language is often only a sure proof of the scanty
attainments of the complainant. As a fact the Bantu languages are
exceedingly rich.’ My own researches fully confirm these remarks. The
question is very naturally raised, Whence do these savages possess so
fine a language? Is it an evolution now in process from something
ruder and more savage or from something inarticulate? The marked
similarity of the dialects points to a common origin; their richness,
superiority, and the regularity of the individual character maintained
over so large an area, give a high idea of the original language which
was spoken before they separated.
Heathenism is degrading, and under its influence everything is
going backwards. We are led by the evidence of the language to look
for a better, nobler origin of the race, rather than to consider it an
evolution from something infinitely lower. The Bantu languages are as
far removed from others of the continent as English is from Turkish or
Chinese. Some earlier writers have endeavoured to trace similarities,
but later research has proved that they do not exist. The origin of the
race must ever remain a mystery. What, when, and where, cannot be
ascertained, for no memorials exist in books or monuments. The Bantu
race and languages cannot be an evolution from something inferior;
they are a degradation from something superior. Coastwards there are
traditions of change and movement on the part of the people; in the
east and on the south marauding tribes and slave-hunters have
devastated large tracts of country, but there is no sign of general
movement on the part of the Bantus.
The traditions of countries along the coast where white men have
long settled speak of much greater, more powerful kingdoms in the
past; and after due allowance has been made for exaggeration, it is too
evident that the kings of Congo, Kabinda, Loango, and Angola, exerted
at one time far more influence than they do to-day. Indeed, the King of
Congo is the only chief who maintains his style and title; the others
have become extinct during this century. We find then the whole
country in a state of disintegration; every town a separate state, and its
chief, to all practical purposes, independent.
Makoko, the Teke chief with whom De Brazza made his famous
treaty, is said to have levied taxes on the north bank people near his
town. The King of Congo used to receive a tribute from the remnants
of the old Congo empire; but to-day he has to content himself with
levying a mild blackmail on passing caravans, and receives a present,
when he gives the ‘hat’ and the insignia of office to those who succeed
to chieftainships over which in olden times the kings exercised
suzerainty. Few, indeed, of those acknowledge him to-day even to that
extent.
These independent townships group themselves into tribes and
tribelets; it is, however, a matter of great difficulty to learn the tribal
names, which are best obtained from neighbours. The old Congo
empire formerly included the countries on the south bank from the
coast to Stanley Pool, and southward to the Bunda-speaking people of
Ngola (Angola), while homage was rendered by the kings of Loango
and Kabinda. To-day the influence of the king is merely nominal outside
his town. He is respected, however, in a radius of thirty or forty miles,
but seldom if ever interferes in any matters.
San Salvador is situated on a plateau 1,700 feet above the sea,
about two-and-a-half miles long by one mile wide. Broad valleys 300
feet deep surround it, and in the south flows the little river Lueji, a
tributary of the Lunda-Mpozo.
There are abundant traces of its former importance. The ruins of a
stone wall, two feet thick and fifteen feet high, encircle the town. The
ruins of the cathedral are very interesting, and show it to have been a
very fine building. The material is an ironstone conglomerate, while the
lime was burnt from rock in the neighbourhood.
Amid the strong rich grass that covers the plateau exist ruins of
some twenty-six buildings, which are said to have been churches, while
straight lines of mingomena bushes mark the sites of suburban villas
and hamlets. The story runs that the old kings kept up the population
of the Mbanza (chief town) by raids into the country. The natives of a
town forty miles away would wake up in the morning to find
themselves surrounded. As they came out of their houses they would
be killed, until there was no further show of resistance; then those who
remained would be deported to the capital and be compelled to build
there, while many would be sold to the slave-traders on the coast.
These days are for ever past. Men-of-war have so closely watched the
coast that the slave trade has languished and died, except in Angola,
where it exists under a finer name, the slave being considered a
‘Colonial,’ while Portuguese ingenuity and corruption arrange for
‘emigration’ to the islands San Thomé, Principe, and even to the
Bissagos.
While these slave raids in Congo are things of the past, a mild
domestic slavery exists among the natives. In most cases the slaves
are more like feudal retainers or serfs. A man of means invests his
money in slaves, and thereby becomes more independent, for his slave
retainers can support him in difficulties with his neighbours. It
frequently happens that he builds a stockade at a little distance from
the town in which he has been brought up, and this becomes the
nucleus of a new town. In the latter end of the rainy season and the
beginning of the ‘dries,’ they will cut nianga grass, the long six-foot
blades of which spring up out of the ground, and have no stem or
nodes. This grass is dried and used for the covering of the huts. Stems
of palm fronds are also trimmed and split. Papyrus is brought from the
marshes, and strips of its green skin twisted into string, with which
they tie together securely the posts and rafters, so that they may stand
the strain of the fierce tornadoes which sweep the country.
MANNER OF DRESSING THE HAIR.
CHAPTER IV.
P
erhaps the home life of the Congo folk may be best depicted if
some familiar scenes are described.
The women are content often with a rag for clothing. They wear
a grass stem three inches long through the nose, and a dirty rag for
an earring. The hair is matted with a mixture of oil and vegetable
charcoal; and if a lady happen to be in mourning the same filthy
compound is smeared over her face.
With the advent of white men this sad picture has begun to
change. The Livingstone Inland Mission (American Baptists) and the
International Association have stations among them; their transport
and that of the Baptist Missionary Society (English) passes through
the country. The people are coming forward as carriers; they sell
their goats, fowls, etc., are getting cloth; and in this short time a
change for the better is apparent. Here lies all the difference
between the degraded and the higher types of the African. The
intellect of the one is stagnant, while the other has everything to
quicken it.
As children the better class will compare favourably with English
boys; bright, sharp, anxious to learn, they push on well with their
studies. Our schools are full of promise. At Stanley Pool the other
day the boys were much concerned because a new boy had
mastered his alphabet the first day. They all felt that he was too
clever.
The future of these interesting people is full of the brightest
hope. Give them the Gospel, and with it the advantages of
education, and books to read; quicken within them tastes which will
render labour a necessity and a pleasure; give them something high
and noble to work and live for; and we shall see great and rapid
changes. Christian Missions are no experiment. We have to deal with
a vigorous race that will repay all that Christian effort can do on their
behalf.
CHAPTER V.
T
here is nothing that can be said to take the place of a religion
throughout the whole region of the Congo. There is no
idolatry, no system of worship; nothing but a vague
superstition, a groping in the dark, the deepest, saddest ignorance,
without a hope of light. The people have the name of God, but know
nothing further about Him. The idea is not, however, of an evil
being, or they would wish to propitiate him. A mild and gentle chief
gets little respect or honour. A man who is hard and stern, reckless
of life, is feared and respected. Hence, as they fear no evil from
God, they do not trouble themselves about Him in any way—never
even invoke Him. Perhaps it may be because they regard Him as
beyond their reach and ken, or careless of them.
C
annibalism is not met with on the Congo until we ascend almost
to Stanley Pool. The first tribe of the Bateke—the Alali—on the
north bank, are said to eat human flesh sometimes, but only
those who have been killed for witchcraft. The Amfuninga, or Amfunu,
the next tribe of Bateke, are also credited with the same vice. It is only
a report; we have no evidence of the fact. From Bolobo (2° South lat.)
upwards it is known to be a custom. White men have had to witness
the cutting up of victims, being powerless to prevent the act. When
remonstrated with, the natives have replied, ‘You kill your goats, and
no one finds fault with you; let us kill our meat then.’ When eating their
ghastly meal, the parents give morsels of the cooked flesh to the little
ones, to give them the taste for such food.
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.
textbookfull.com