Python Distilled 1st edition - eBook PDF pdf download
Python Distilled 1st edition - eBook PDF pdf download
download
https://ebookluna.com/download/python-distilled-ebook-pdf/
https://ebookluna.com/product/ebook-pdf-building-python-programs-1st-
edition/
ebookluna.com
https://ebookluna.com/product/python-for-dummies-1st-edition-pdf-
version/
ebookluna.com
https://ebookluna.com/download/problem-solving-and-python-programming-
ebook-pdf/
ebookluna.com
https://ebookluna.com/download/programming-and-problem-solving-with-
python-ebook-pdf/
ebookluna.com
Data Structures & Algorithms in Python 1st Edition John
Canning - eBook PDF
https://ebookluna.com/download/data-structures-algorithms-in-python-
ebook-pdf-2/
ebookluna.com
https://ebookluna.com/download/data-structures-algorithms-in-python-
ebook-pdf/
ebookluna.com
https://ebookluna.com/download/r-and-python-for-oceanographers-a-
practical-guide-with-applications-ebook-pdf/
ebookluna.com
https://ebookluna.com/product/ebook-pdf-starting-out-with-python-4th-
edition/
ebookluna.com
https://ebookluna.com/product/ebook-pdf-python-programming-in-
context-3rd-edition/
ebookluna.com
Python Distilled
This page intentionally left blank
Python Distilled
David M. Beazley
The author and publisher have taken care in the preparation of this book, but make no expressed or
implied warranty of any kind and assume no responsibility for errors or omissions. No liability is assumed
for incidental or consequential damages in connection with or arising out of the use of the information or
programs contained herein.
For information about buying this title in bulk quantities, or for special sales opportunities (which may
include electronic versions; custom cover designs; and content particular to your business, training goals,
marketing focus, or branding interests), please contact our corporate sales department
at corpsales@pearsoned.com or (800) 382-3419.
For questions about sales outside the U.S., please contact intlcs@pearson.com.
All rights reserved. This publication is protected by copyright, and permission must be obtained from the
publisher prior to any prohibited reproduction, storage in a retrieval system, or transmission in any form or
by any means, electronic, mechanical, photocopying, recording, or likewise. For information regarding
permissions, request forms and the appropriate contacts within the Pearson Education Global Rights &
Permissions Department, please visit www.pearson.com/permissions.
ISBN-13: 978-0-13-417327-6
ISBN-10: 0-13-417327-9
ScoutAutomatedPrintCode
Contents
Preface xiii
1 Python Basics 1
1.1 Running Python 1
1.2 Python Programs 2
1.3 Primitives, Variables, and
Expressions 3
1.4 Arithmetic Operators 5
1.5 Conditionals and Control Flow 7
1.6 Text Strings 9
1.7 File Input and Output 12
1.8 Lists 13
1.9 Tuples 15
1.10 Sets 17
1.11 Dictionaries 18
1.12 Iteration and Looping 21
1.13 Functions 22
1.14 Exceptions 24
1.15 Program Termination 26
1.16 Objects and Classes 26
1.17 Modules 30
1.18 Script Writing 32
1.19 Packages 33
1.20 Structuring an Application 34
1.21 Managing Third-Party Packages 35
1.22 Python: It Fits Your Brain 36
5 Functions 101
5.1 Function Definitions 101
5.2 Default Arguments 101
5.3 Variadic Arguments 102
5.4 Keyword Arguments 103
5.5 Variadic Keyword Arguments 104
5.6 Functions Accepting All Inputs 104
5.7 Positional-Only Arguments 105
5.8 Names, Documentation Strings, and Type
Hints 106
5.9 Function Application and Parameter
Passing 107
5.10 Return Values 109
5.11 Error Handling 110
5.12 Scoping Rules 111
5.13 Recursion 114
viii Contents
6 Generators 139
6.1 Generators and yield 139
6.2 Restartable Generators 142
6.3 Generator Delegation 142
6.4 Using Generators in Practice 144
6.5 Enhanced Generators and yield
Expressions 146
6.6 Applications of Enhanced
Generators 148
6.7 Generators and the Bridge to
Awaiting 151
6.8 Final Words: A Brief History of
Generators and Looking
Forward 152
Index 321
Preface
More than 20 years have passed since I authored the Python Essential Reference. At that time,
Python was a much smaller language and it came with a useful set of batteries in its
standard library. It was something that could mostly fit in your brain. The Essential Reference
reflected that era. It was a small book that you could take with you to write some Python
code on a desert island or inside a secret vault. Over the three subsequent revisions, the
Essential Reference stuck with this vision of being a compact but complete language
reference —because if you’re going to code in Python on vacation, why not use all of it?
Today, more than a decade since the publication of the last edition, the Python world is
much different. No longer a niche language, Python has become one of the most popular
programming languages in the world. Python programmers also have a wealth of
information at their fingertips in the form of advanced editors, IDEs, notebooks, web
pages, and more. In fact, there’s probably little need to consult a reference book when
almost any reference material you might want can be conjured to appear before your eyes
with the touch of a few keys.
If anything, the ease of information retrieval and the scale of the Python universe
presents a different kind of challenge. If you’re just starting to learn or need to solve a new
problem, it can be overwhelming to know where to begin. It can also be difficult to
separate the features of various tools from the core language itself. These kinds of problems
are the rationale for this book.
Python Distilled is a book about programming in Python. It’s not trying to document
everything that’s possible or has been done in Python. Its focus is on presenting a modern
yet curated (or distilled) core of the language. It has been informed by my years of teaching
Python to scientists, engineers, and software professionals. However, it’s also a product of
writing software libraries, pushing the edges of what makes Python tick, and finding out
what’s most useful.
For the most part, the book focuses on Python programming itself. This includes
abstraction techniques, program structure, data, functions, objects, modules, and so
forth— topics that will well serve programmers working on Python projects of any size.
Pure reference material that can be easily obtained via an IDE (such as lists of functions,
names of commands, arguments, etc.) is generally omitted. I’ve also made a conscious
choice to not describe the fast-changing world of Python tooling —editors, IDEs,
deployment, and related matters.
Perhaps controversially, I don’t generally focus on language features related to large-scale
software project management. Python is sometimes used for big and serious things—
comprised of millions upon millions of lines of code. Such applications require specialized
tooling, design, and features. They also involve committees, and meetings, and decisions
to be made about very important matters. All this is too much for this small book. But
xiv Preface
perhaps the honest answer is that I don’t use Python to write such applications— and
neither should you. At least not as a hobby.
In writing a book, there is always a cut-off for the ever-evolving language features. This
book was written during the era of Python 3.9. As such, it does not include some of the
major additions planned for later releases — for example, structural pattern matching.
That’s a topic for a different time and place.
Last, but not least, I think it’s important that programming remains fun. I hope that my
book will not only help you become a productive Python programmer but also capture
some of the magic that has inspired people to use Python for exploring the stars, flying
helicopters on Mars, and spraying squirrels with a water cannon in the backyard.
Acknowledgments
I’d like to thank the technical reviewers, Shawn Brown, Sophie Tabac, and Pete Fein, for
their helpful comments. I’d also like to thank my long-time editor Debra Williams Cauley
for her work on this and past projects. The many students who have taken my classes have
had a major if indirect impact on the topics covered in this book. Last, but not least, I’d
like to thank Paula, Thomas, and Lewis for their support and love.
This chapter gives an overview of the core of the Python language. It covers variables,
data types, expressions, control flow, functions, classes, and input/output. The chapter
concludes with a discussion of modules, script writing, packages, and a few tips on
organizing larger programs. This chapter is not trying to provide comprehensive coverage
of every feature, nor does it concern itself with all of the tooling that might surround a
larger Python project. However, experienced programmers should be able to extrapolate
from the material here to write more advanced programs. Newcomers are encouraged to
try the examples in a simple environment, such as a terminal window and a basic text
editor.
Certain environments may display a different prompt. The following output is from
ipython (an alternate shell for Python):
In [2]:
Regardless of the exact form of output you see, the underlying principle is the same.
You type a command, it runs, and you immediately see the output.
Python’s interactive mode is one of its most useful features because you can type any
valid statement and immediately see the result. This is useful for debugging and
experimentation. Many people, including the author, use interactive Python as their
desktop calculator. For example:
>>> 6000 + 4523.50 + 134.25
10657.75
>>> _ + 8192.75
18850.5
>>>
When you use Python interactively, the variable _ holds the result of the last operation.
This is useful if you want to use that result in subsequent statements. This variable only
gets defined when working interactively, so don’t use it in saved programs.
You can exit the interactive interpreter by typing quit() or the EOF (end of file)
character. On UNIX, EOF is Ctrl+D; on Windows, it’s Ctrl+Z.
Python source files are UTF-8-encoded text files that normally have a .py suffix. The
# character denotes a comment that extends to the end of the line. International (Unicode)
characters can be freely used in the source code as long as you use the UTF-8 encoding
(this is the default in most editors, but it never hurts to check your editor settings if you’re
unsure).
1.3 Primitives, Variables, and Expressions 3
To execute the hello.py file, provide the filename to the interpreter as follows:
shell % python3 hello.py
Hello World
shell %
It is common to use #! to specify the interpreter on the first line of a program, like this:
#!/usr/bin/env python3
print('Hello World')
On UNIX, if you give this file execute permissions (for example, by chmod +x
hello.py), you can run the program by typing hello.py into your shell.
On Windows, you can double-click on a .py file or type the name of the program into
the Run command on the Windows Start menu to launch it. The #! line, if given, is used
to pick the interpreter version (Python 2 versus 3). Execution of a program might take
place in a console window that disappears immediately after the program completes—
often before you can read its output. For debugging, it’s better to run the program within
a Python development environment.
The interpreter runs statements in order until it reaches the end of the input file. At
that point, the program terminates and Python exits.
A variable is a name that refers to a value. A value represents an object of some type:
x = 42
Sometimes you might see a type explicitly attached to a name. For example:
x: int = 42
The type is merely a hint to improve code readability. It can be used by third-party
code-checking tools. Otherwise, it is completely ignored. It does not prevent you from
assigning a different kind of value later.
An expression is a combination of primitives, names, and operators that produces a
value:
2 + 3 * 4 # -> 14
4 Chapter 1 Python Basics
The while statement tests the conditional expression that immediately follows. If the
tested condition is true, the body of the while statement executes. The condition is
then retested and the body executed again until the condition becomes false. The body
of the loop is denoted by indentation. Thus, the three statements following while in
interest.py execute on each iteration. Python doesn’t specify the amount of required
indentation, as long as it’s consistent within a block. It is most common to use four spaces
per indentation level.
One problem with the interest.py program is that the output isn’t very pretty. To
make it better, you could right-align the columns and limit the precision of principal
to two digits. Change the print() function to use a so-called f-string like this:
print(f'{year:>3d} {principal:0.2f}')
In the f-string, variable names and expressions can be evaluated by enclosing them in
curly braces. Optionally, each substitution can have a formatting specifier attached to it.
'>3d' means a three-digit decimal number, right aligned. '0.2f' means a floating-point
number with two decimal places of accuracy. More information about these formatting
codes can be found in Chapter 9.
Now the output of the program looks like this:
1 1050.00
2 1102.50
3 1157.62
4 1215.51
5 1276.28
1.4 Arithmetic Operators 5
Operation Description
x + y Addition
x - y Subtraction
x * y Multiplication
x / y Division
x // y Truncating division
x ** y Power (x to the y power)
x % y Modulo (x mod y). Remainder.
–x Unary minus
+x Unary plus
The division operator (/) produces a floating-point number when applied to integers.
Therefore, 7/4 is 1.75. The truncating division operator //, also known as floor division,
truncates the result to an integer and works with both integers and floating-point
numbers. The modulo operator returns the remainder of the division x // y. For
example, 7 % 4 is 3. For floating-point numbers, the modulo operator returns the
floating-point remainder of x // y, which is x – (x // y) * y.
In addition, the built-in functions in Table 1.2 provide a few more commonly used
numerical operations.
The round() function implements “banker’s rounding.” If the value being rounded is
equally close to two multiples, it is rounded to the nearest even multiple (for example, 0.5
is rounded to 0.0, and 1.5 is rounded to 2.0).
Integers provide a few additional operators to support bit manipulation, shown in
Table 1.3.
6 Chapter 1 Python Basics
Operation Description
One would commonly use these with binary integers. For example:
a = 0b11001001
mask = 0b11110000
x = (a & mask) >> 4 # x = 0b1100 (12)
In this example, 0b11001001 is how you write an integer value in binary. You could
have written it as decimal 201 or hexadecimal 0xc9, but if you’re fiddling with bits, binary
makes it easier to visualize what you’re doing.
The semantics of the bitwise operators assumes that the integers use a two’s
complement binary representation and that the sign bit is infinitely extended to the left.
Some care is required if you are working with raw bit patterns that are intended to map to
native integers on the hardware. This is because Python does not truncate the bits or allow
values to overflow — instead, the result will grow arbitrarily large in magnitude. It’s up to
you to make sure the result is properly sized or truncated if needed.
To compare numbers, use the comparison operators in Table 1.4.
Operation Description
x == y Equal to
x != y Not equal to
x < y Less than
x > y Greater than
x >= y Greater than or equal to
x <= y Less than or equal to
Operator Description
For these, you can write the following shortened operation instead:
x += 1
y *= n
This shortened form of update can be used with any of the +, -, *, **, /, //, %, &, |, ^,
<<, >>operators. Python does not have increment (++) or decrement (--) operators found
in some other languages.
The bodies of the if and else clauses are denoted by indentation. The else clause is
optional. To create an empty clause, use the pass statement, as follows:
if a < b:
pass # Do nothing
else:
print('Computer says No')
If you are assigning a value in combination with a test, use a conditional expression:
maxval = a if a > b else b
Sometimes, you may see the assignment of a variable and a conditional combined
together using the := operator. This is known as an assignment expression (or more
colloquially as the “walrus operator” because := looks like a walrus tipped over on its
side —presumably playing dead). For example:
x = 0
while (x := x + 1) < 10: # Prints 1, 2, 3, ..., 9
print(x)
print('Done')
The continue statement skips the rest of the loop body and goes back to the top of the
loop. For example:
x = 0
while x < 10:
x += 1
if x == 5:
continue # Skips the print(x). Goes back to loop start.
print(x)
print('Done')
1.6 Text Strings 9
a = 'Hello World'
b = "Python is groovy"
c = '''Computer says no.'''
d = """Computer still says no."""
The same type of quote used to start a string must be used to terminate it. Triple-
quoted strings capture all the text until the terminating triple quote — as opposed to single-
and double-quoted strings which must be specified on one logical line. Triple-quoted
strings are useful when the contents of a string literal span multiple lines of text:
print('''Content-type: text/html
Immediately adjacent string literals are concatenated into a single string. Thus, the
above example could also be written as:
print(
'Content-type: text/html\n'
'\n'
'<h1> Hello World </h1>\n'
'Clock <a href="http://www.python.org">here</a>\n'
)
Although this is only using simple variable names, any valid expression can appear. For
example:
base_year = 2020
...
print(f'{base_year + year:>4d} {principal:0.2f}')
As an alternative to f-strings, the format() method and % operator are also sometimes
used to format strings. For example:
print('{0:>3d} {1:0.2f}'.format(year, principal))
print('%3d %0.2f' % (year, principal))
10 Chapter 1 Python Basics
To extract a substring, use the slicing operator s[i:j]. It extracts all characters from s
whose index k is in the range i <= k < j. If either index is omitted, the beginning or end
of the string is assumed, respectively:
c = a[:5] # c = 'Hello'
d = a[6:] # d = 'World'
e = a[3:8] # e = 'lo Wo'
f = a[-5:] # f = 'World'
Strings have a variety of methods for manipulating their contents. For example, the
replace() method performs a simple text replacement:
g = a.replace('Hello', 'Hello Cruel') # f = 'Hello Cruel World'
Table 1.6 shows a few common string methods. Here and elsewhere, arguments
enclosed in square brackets are optional.
Method Description
A few days after the events just related, the following scene took
place at Mr. Howard's office in Golden Square.
It was about four in the afternoon, and the lawyer was seated in his
private room, at a table covered with papers, when a clerk entered
and announced that Sir Christopher Blunt and his lady had just
arrived.
"His lady with him—eh!" exclaimed the solicitor. "Well—show them in
at once."
And, accordingly, in a few minutes the worthy knight, with Charlotte
—or, we beg her pardon, Lady Blunt—hanging upon his arm, entered
the office.
The old gentleman was all smiles—but the quick eye of Mr. Howard
immediately perceived that they were to some extent forced and
feigned; and that beneath his jaunty aspect there was not altogether
the inward contentment, much less the lightsome glee, of a happy
bridegroom.
As for Lady Blunt—she was attired in the richest manner, and in all
the colours of the rainbow,—looking far too gaudy to be either
genteel or fashionable.
"My dear Sir Christopher, I am quite charmed to see you" exclaimed
Mr. Howard, rising to welcome his client and the bride. "Your
ladyship——"
"Yes—this is my loving and beloved Lady Blunt, Howard," said the
knight pompously: "a delightful creature, I can assure you—and who
has vowed to devote herself to my happiness."
"Come now, you great stupid!" said the lady; "finish your business
here, and let us see about the new carriage. Of all places in the
world, I hate a lawyer's office—ever since I was once summoned to
a Court of Conscience for seventeen shillings and ninepence-
halfpenny, and had to call on the thief of an attorney to get him to
take it by instalments of sixpence a-week. So, you see, I can't a-bear
the lawyers. No offence, sir," she added, turning towards Mr.
Howard; "but I always speak my mind; and I think it's best."
"My dear creature—my sweet love!" ejaculated Sir Christopher,
astounded at this outbreak of petulance on the part of his loving and
beloved wife.
"Pray do not distress yourself, my dear Sir Christopher," said the
lawyer. "We are accustomed to receive sharp rebukes from the ladies
sometimes," he added, with as courteous a smile as he could
possibly manage under the circumstances. "But pray be seated. Will
your ladyship take this chair?"—and he indicated the one nearest to
the fire.
Lady Blunt quitted her husband's arm, but made an imperious sign
for him to bring his chair close to hers; and he obeyed her with a
submission which left no doubt in the lawyer's mind as to the empire
already asserted by the bride.
"I am very glad you have called to-day, Sir Christopher," said the
lawyer; "for——"
"He couldn't very well come before, sir," interrupted Lady Blunt;
"because we only came back from the matrimonial trip last night."
Mr. Howard bowed, and was preparing to continue, when the knight
exclaimed, "My dear sir, what is all this to-do about the highwayman
who robbed me of the two thousand pounds? I thought I told you so
particularly that I would rather no steps should be taken in the
matter; and now—the moment I come back to town——"
"Instead of having all our time to ourselves, to gad about cozie
together," again interrupted Lady Blunt, "we are forced to come
bothering here at a lawyer's office."
"The ends of justice must be met, Lady Blunt," said Mr. Howard drily.
"In consequence of particular information which I received, I caused
this Thomas Rainford to be apprehended; and I appeal to Sir
Christopher himself—who has served the high office of Sheriff——"
"And once stood as a candidate for the aldermanic gown of
Portsoken, until I was obliged to cut those City people," added the
knight, drawing himself up.
"And why should you cut the City people?" demanded his wife. "For
my part, I'd sooner see the Lord Mayor's show than Punch and Judy
any day; and that's saying a great deal—for no one can be more
fonder of Punch and Judy than me."
"My dear Charlotte," exclaimed the knight, who now seemed to be
sitting on thorns, "you——"
"Charlotte at home—Lady Blunt in public, Sir Christopher—if you
please," interrupted the bride. "But pray let Mr. Howard get to the
end of this business."
"Well, my dear," exclaimed Sir Christopher, "if it annoys you, why
would you come? I assured you how unusual it was for ladies to
accompany their husbands to the office of their solicitors——"
"Oh! I dare say, Sir Christopher!" cried Charlotte. "You don't think
that I'm going to trust you out of my sight, do you now? I'm not
quite such a fool as you take me for. Why, even when we are
walking along the street together, I can see your wicked old eye
fixed on the gals——"
"Lady Blunt!" exclaimed the knight, becoming literally purple; "you—
you—you do me an injustice!"
"So much the better. I hope I am wrong—for both of our sakes,"
returned her ladyship. "Depend upon it——But, no matter now: let
Mr. Howard get on with his story."
"With your permission, madam, I shall be delighted to do so," said
the lawyer. "I was observing just now that having received particular
information, I caused this scoundrel Thomas Rainford, alias Captain
Sparks, to be apprehended; and on Monday morning, Sir
Christopher, you must attend before the magistrate to give your
evidence."
"But who authorised you to proceed in this affair, Mr. Howard?"
demanded the knight.
"What a strange question?" exclaimed the lawyer, evidently unwilling
to give a direct answer to it. "Only reflect for a moment, my dear Sir
Christopher. A robbery is committed—you, your nephew, and myself
are outwitted—laughed at—set at defiance,—and when an
opportunity comes in my way, I very naturally adopt the best
measures to punish the rogue."
"Quite proper too, sir," said Lady Blunt. "The idea of any one daring
to laugh at Sir Christopher! I'd scratch the villain's eyes out, if I had
him here. To laugh at Sir Christopher, indeed! Does he look like a
man who is meant to be laughed at?"
Lady Blunt could not have chosen a more unfortunate opportunity to
ask this question; for her husband at that moment presented so
ludicrous an appearance, between his attempts to look pleasant and
his fears lest he already seemed a henpecked old fool in the eyes of
his solicitor, that a man possessing less command over himself than
Mr. Howard would have laughed outright.
But with the utmost gravity in the world, the lawyer assured her
ladyship that nothing could be more preposterous than to laugh at a
gentleman of Sir Christopher Blunt's rank and importance; and he
also declared that in arresting Thomas Rainford, he had merely felt a
proper anxiety to punish one who had dared to ridicule the knight,
after having robbed him.
Lady Blunt was one of those capricious women who will laugh at
their husbands either as a matter of pastime or for the purpose of
manifesting their own independence and predominant sway, but who
cannot bear the idea of any other person taking a similar liberty. She
therefore expressed her joy that Mr. Howard had caused Rainford to
be apprehended, and declared, of her own accord, that Sir
Christopher should attend to give his evidence on the ensuing
Monday—"for she would go with him!"
"Well, my dear, since such is your pleasure," observed the knight,
"there is no more to be said upon the subject. I will go, my love; and
I think that when the magistrate hears my evidence, he will feel
convinced that I know pretty well how to aid the operation of the
laws, and that I have not been a Sheriff for nothing. Although
sprung from a humble origin——"
"Oh! pray don't begin that nonsense, Sir Christopher!" exclaimed the
lady; "or I shall faint. It is really quite sickening."
At that moment the door opened somewhat violently; and Mr. Frank
Curtis entered the room.
"Ah! Sir Christopher, my jolly old cock—how are you?" exclaimed that
highly respectable young gentleman, whose face was dreadfully
flushed with drinking, and who smelt so strong of cigars and rum-
punch that his presence instantly produced the most overpowering
effect.
"Mr. Curtis!" began the knight, rising from his chair, and drawing
himself up to his full height, "I——"
"Come—it's no use to be grumpy over it, uncle," interrupted Frank.
"Matrimony doesn't seem to agree with you very well, since you're
so soon put out of humour. Ah! my dear Char——my dear aunt, I
mean—beg your pardon—quite a mistake, you know;—but really you
look charming this afternoon."
"Get out with you, do!" cried Lady Blunt, who was somewhat
undecided how to treat Mr. Curtis.
"What! doesn't matrimony agree with you, either, my dear and much
respected aunt?" ejaculated Frank. "Why, I once knew a lady who
was in a galloping consumption—given up, in fact, and the
undertaker who lived over the way had already begun to make her
coffin—for he knew he should have the order for the funeral; when
all of a sudden a young chap fell in love with her, married her, and
took her to the south of France—where I've been, by the bye—and
brought her home in six months quite recovered, and in a fair way to
present him with a little one—a pledge of affection, as it's called."
"Mr. Curtis, I am surprised at you," exclaimed Sir Christopher, in a
pompous and commanding tone;—"to talk in this way before a lady
who has only recently passed through that trying ordeal."
"I'll be bound to say it wasn't so recent as you suppose, old buck,"
cried Frank, staggering against the lawyer's table.
"Sir, Lady Blunt has only been recently—very recently married, as
you are well aware," said the knight sternly. "And now let me tell
you, sir, that the detestable devices schemed by Miss Mordaunt and
you have recoiled upon yourselves——"
"Miss Mordaunt and me!" exclaimed Frank, now unfeignedly
surprised: "why—I never spoke to Miss Mordaunt in my life!"
"The monster!" half screamed Lady Blunt.
"The audacious liar!" vociferated the knight.
"Pretty names—very pretty," said Frank coolly; "but I'm rather tough,
thank God! and so they won't kill me this time. But I can assure you,
uncle, you've got hold of the wrong end of the stick when you say
that me and Miss Mordaunt planned any thing against you. As I once
observed to my friend the Count of St. Omers,—'My lord,' says I.
—'What?' asks the Marquis.—'My Lord Duke,' I repeated, in a firmer
tone——"
"Cease this nonsense, Mr. Curtis," interrupted Sir Christopher Blunt
sternly.
"Yes—and let us come along, my dear," said Lady Blunt, rising and
taking her husband's arm. "Your nev-vy does smell so horrid of rum
and cigars——"
"And very good things too," cried Frank; "ain't they, Howard? Me and
a party of young fashionables have been keeping it up a bit to-day at
my lodgings—on the strength of my intended marriage with Mrs.
Goldberry, the rich widow——"
"Your marriage, Frank!" exclaimed Sir Christopher. "What—how—
when——"
"Lord bless you, my dear uncle," said Mr. Curtis, swaying himself to
and fro in a very extraordinary manner, "you don't half know what
kind of a fellow I am. While you was away honeymooning and
nonsense——"
"Nonsense, indeed!" exclaimed Lady Blunt, indignantly. "Come, Sir
Christopher—it's no good staying here talking to Mr. Imperance."
"Going to Conduit Street—eh, aunt?" said Frank, with a drunken leer.
"But, by-the-bye, you regularly choused me out of five guineas, you
know, aunt—and something else, too——"
"Eh?—what?" said Sir Christopher, turning back. "Mr. Curtis, do you
dare to accuse Lady Blunt——"
"Of having made a very great fool of me, but a much bigger one of
you, old fellow," added Frank; and, snapping his fingers in his
uncle's face, he exclaimed, "I don't care a penny for you, Sir
Christopher! In a few days I shall marry Mrs. Goldberry—you are
very welcome to be as happy as you can with your Abigail there. So
remember, we're cuts in future, Sir Christopher—since you want to
come the bumptious over me."
The knight was about to reply; but his better-half drew him hastily
away from the lawyer's office, saying, "Come along, you great
stupid! What's the use of staying to dispute with that feller?"
The door closed behind the "happy couple;" and Mr. Frank Curtis,
throwing himself into the chair which Lady Blunt had just quitted,
burst out into a tremendous fit of laughter.
"You have gone too far, Frank—a great deal too far," said the lawyer,
shaking his head disapprovingly. "Sir Christopher has been a good
friend to you; and although he has committed an egregious error in
running off with that filly, still——"
"What do I care?" interrupted Frank. "I proposed to Mrs. Goldberry
yesterday—and she accepted me, after a good deal of simpering and
blushing, and so on. She's got five thousand a year, and lives in
splendid style in Baker Street. I made her believe that I wasn't quite
a beggar myself: but all's fair in love and war, as my friend the late
Prince of St. Omers used to say in his cups. But what about this
fellow Rainford? and how the deuce did he come to be arrested?"
"I received information of his residence," answered Howard coolly;
"and I gave him into custody accordingly."
"It's very odd," continued Frank, "but I met him last Sunday night;
and I don't mind telling you that we went into the middle of Hyde
Park and had an hour's wrestling together, to see who was the
better man. I threw him nineteen times running, and he threw me
seven; then I threw him three times—and he gave in. So we cried
'quits' for old scores, and I gave him my word and honour that
nothing would ever be done against him in respect to the little affair
of the two thousand pounds. You may therefore suppose that I'm
rather vexed——"
"The officers had already received instructions to apprehend him at
the time your alleged wrestling match came off," said the lawyer;
"and your evidence will be required next Monday morning."
"And I suppose the whole affair of the robbery will come out?"
observed Curtis interrogatively.
"Decidedly so. You must state the exact truth—if you can," added
Mr. Howard.
"If I can! Damn it, old fellow, that observation is not quite the thing
—coming from you; and if any body else had uttered it, egad! I'd
send him a hostile message to-morrow morning—as I did to my
most valued friend, the Marquis of Boulogne, when I was in Paris. I'll
just tell you how that was——"
"Not now Frank," interrupted the lawyer; "because I'm very busy. It's
getting on for post time—and I have not a minute to spare. But mind
and be punctual at the Borough police-office on Monday morning at
ten."
"Well—if I must, I must," said Curtis. "But, after all, I think it's rather
too bad—for this Sparks, or Rainford, or whatever his name is,
seems a good kind of fellow, after all."
"The law must take its course, Frank," observed the attorney in an
abrupt, dry manner.
Curtis accordingly took his leave, and returned to his lodgings,
where by dint of cold water applied outwardly and soda-water taken
inwardly, he endeavoured to sober himself sufficiently to pay a visit
to Mrs. Goldberry.
For it was literally true that there was such a lady—that she lived in
splendid style in Baker Street—that Frank had proposed to her—and
that he had been accepted;—but we have deemed it necessary to
give the reader these corroborative assurances on our part,
inasmuch as the whole tale would otherwise have appeared nothing
more nor less than one of the innumerable children of Mr. Curtis's
fertile imagination.
CHAPTER LI.
LORD ELLINGHAM IN THE DUNGEON.
Four weeks had elapsed since the arrest of Tom Rain and the
extraordinary adventure which had snatched the Earl of Ellingham
from the great world and plunged him into a narrow—noisome cell.
Yes—four weeks had the nobleman languished in the terrible
dungeon,—ignorant of where his prison-house was situated—why his
freedom was thus outraged—and who were his persecutors.
Every morning, at about eight o'clock, a small trap in the door of his
cell was opened, and food was passed through to him. A lamp had
been given him the day after he became an inmate of the place; and
oil was regularly supplied for the maintenance of the light. His food
was good, and wine accompanied it;—it was therefore evident that
no petty spite nor mean malignity had led to his captivity.
Indeed, the man who brought him his food assured him that no
harm would befall him,—that his imprisonment was necessary to suit
certain weighty and important interests, but that it would not be
protracted beyond a few weeks,—and that the only reason for
placing him in such a dungeon was because it was requisite to guard
against the possibility of an escape.
Often and often had Lord Ellingham endeavoured to render his
gaoler more communicative; but the man was not to be coaxed into
garrulity. Neither did he ever allow the nobleman to catch a glimpse
of his features, when he brought the food to the trap-door. He
invariably stood on one side, and spoke in a feigned tone when
replying to any question to which he did vouchsafe an answer.
The day after his strange and mysterious arrest, Arthur received
from this man the assurances above mentioned; and a considerable
weight was thereby removed from his mind. His imprisonment was
not to be eternal: a few weeks would see the term of the necessity
that had caused it. But still he grieved—nay, felt shocked to think of
the state of suspense in which those who cared for him would
remain during his long absence. This source of affliction he
mentioned to the man who attended upon him; and the reply was to
some extent satisfactory.
"I will supply you with writing materials, and you can address letters
to your friends, stating that sudden business has called you abroad—
to France, for instance; and that you may probably be absent six
weeks. Write in this manner—the excuse will at least allay any
serious fears that may be entertained concerning you; and those
letters shall be sent through the post to the persons to whom they
are addressed. But you must deliver them unsealed into my hands,
that I may satisfy myself as to the real nature of their contents."
Small as the satisfaction resulting from this proceeding could be to
Lord Ellingham, it was still far preferable to the maintenance of a
rigid silence in respect to his friends. He accordingly wrote a laconic
letter in the sense suggested by his gaoler; and addressed copies to
Lady Hatfield, Thomas Rainford, and Mr. de Medina. The next time
his gaoler visited him—or rather, came to the door of the dungeon,
the prisoner was informed that the three letters had been duly
forwarded through the twopenny post.
The reader will scarcely require to be informed of the mental anxiety
which the nobleman suffered during his incarceration. This was
naturally great—very great. He was also frequently plunged in the
most bewildering conjectures relative to the authors, the motives,
and the locality of his imprisonment. Nor less did he grieve—Oh!
deeply grieve, when he thought of the surprise—the alarm—and the
sorrow with which Lady Hatfield on one side and Rainford on the
other must view his mysterious absence. He had left the former with
the intention of seeing the latter, and she would naturally expect him
to return if for no other reason than to give her an account of their
interview; and he had quitted Rainford with the promise to perform
a certain task, and also having pledged himself to use his influence
and his wealth in his behalf.
The idea of the feelings that must be entertained by Rainford
relative to his absence, afflicted him more than any other. That
generous-hearted man had told him to keep his coronet and his
fortune to the prejudice of him—the elder brother, legitimately born;
and yet that interview in Horsemonger Lane Gaol seemed destined
to be the last which they were to have together! What would the
poor prisoner think when the Earl returned not, and when a letter
containing a cold and wretched excuse was put into his hands? Oh!
this was the maddening—maddening thought; and the Earl shrank
from it far more appalled than from the stern reality of his dungeon!
Because Rainford might be judged, and, alas! the law might take its
course—its fatal course—ere he, the Earl, could stretch out a hand
to save that generous-hearted half-brother.
But amidst all the bitter and bewildering reflections which tormented
him during his imprisonment of four weeks in that dungeon of
unknown neighbourhood, there was still a predominant idea—a
gleam of hope, which, apart from the assurance that his captivity
would soon have a term, cheered and animated him often.
For whither will not the rays of Hope penetrate? Even when Hope is
really gone, her work is often done by Despair; and the latter
feeling, in its extreme, is thus often akin to Hope herself.
The hope, then, that cheered and animated the Earl at times, was—
Escape!
Yes: he yearned to quit that dungeon, not so much for his own sake
—oh! not nearly so much, as for that of his half-brother, who was
involved in such peril, and who needed influence and interest to
save him! For the Earl well knew that the law in criminal cases is not
so tardy as in civil matters; and that to take away a man's life, all its
machinery is set into rapid motion—although to settle his claims to a
fortune or to give him justice against his neighbour, it is, heaven
knows! heart-breakingly slow and wearisome!
To send a man to the scaffold, takes but a few weeks at the Old
Bailey:—to decide the right of this man or that man to a particular
estate, or legacy, occupies years and years in the Court of Chancery.
Oh! how thirsty do our legislators appear to drink human blood. How
rapidly all technicalities and causes of delay are cleared away when
the capital offender stands before his judge! A day—perhaps an hour
is sufficient to decide the death of a human being; but half a century
may elapse ere the conflicting claims to an acre of land or a few
thousand pounds can be settled elsewhere.
And, strange—ah! and monstrous, too, is it, that the man who loses
a case in which he sues his neighbour for twenty pounds, may
appeal to another tribunal—have a new trial granted—and, losing
that also, perhaps obtain a third investigation of the point at issue,
and thus three verdicts in that beggarly business! But the man who
is doomed to die—who loses his case against the criminal prosecutor
—cannot appeal to another tribunal. No judges sit solemnly in banco
for him: one verdict is sufficient to take away a life. Away with him
to the scaffold! In this great commercial country, twenty pounds—
consisting of pieces of paper printed upon and stamped with
particular figures—are of more consequence than a being of flesh
and blood! What though this being of flesh and blood may have
others—a wife and children—dependent on him? No matter! Give
him not the chance of a new trial: let one judge and one jury suffice
to consign him to the hangman! There can be no appeal—no re-
investigation for his case, although it be a case of life and death: but
away with him to the scaffold!
What blood-thirsty and atrocious monsters have our law-givers
been: what cruel, inhuman beings are they still, to perpetuate so
abominable—so flagrant—so infamous a state of jurisprudence! For
how many have been hanged, though innocent,—their guiltlessness
transpiring when it is too late! But there is no court of appeal for the
man accused of a capital crime: he is a dog who has got a bad name
—and public opinion dooms him to be hanged, days and weeks
before the jury is sworn or the judge takes his seat to try him!
And wherefore is not this infamous state of the law, which allows
appeals to the case of money-claims, but none to the case of capital
accusations,—wherefore is not this state of the law altered? Because
our legislators are too much occupied with their own party
contentions and strifes;—because they are ever engaged in battling
for the Ministerial benches—the "loaves and fishes" of power:
because it seems to them of more consequence to decide whether
Sir Robert Peel or Lord John Russell shall be Prime Minister—whether
the Conservatives or the Whigs shall hold the reins of power. Or else,
gentle reader, the condition of Greece—or Spain—or Turkey,—or
even perhaps of Otaheite,—is a matter of far greater importance
than the lives of a few miserable wretches in the condemned cells of
criminal gaols!
But, in our estimation—and we have the misfortune to differ from
the legislators of the country—the life of one of those wretches is of
far greater consequence than the state of tyrant-ridden Greece—the
Spanish marriages—the quarrels of the Sultan and his Pachas—or
the miserable squabbles of hypocritical English missionaries and a
French governor in Tahiti. Yes—in our estimation, the life of one man
outweighs all such considerations; and we would rather see half a
session of Parliament devoted to the discussion of the grand
question of the Punishment of Death, than one single day of that
session given to all the foreign affairs that ever agitated in a
Minister's brain.