Think Python 1st Edition Allen B. Downey download
Think Python 1st Edition Allen B. Downey download
Downey pdf
download
https://ebookname.com/product/think-python-1st-edition-allen-b-
downey/
https://ebookname.com/product/think-stats-exploratory-data-
analysis-second-edition-allen-b-downey/
https://ebookname.com/product/think-java-how-to-think-like-a-
computer-scientist-1st-edition-allen-b-downey/
https://ebookname.com/product/computing-handbook-computer-
science-and-software-engineering-3ed-edition-allen-b-tucker/
https://ebookname.com/product/the-geometry-of-special-
relativity-1st-edition-tevian-dray/
Music in the Holocaust Confronting Life in the Nazi
Ghettos and Camps Oxford Historical Monographs Gilbert
https://ebookname.com/product/music-in-the-holocaust-confronting-
life-in-the-nazi-ghettos-and-camps-oxford-historical-monographs-
gilbert/
https://ebookname.com/product/the-three-dimensional-navier-
stokes-equations-classical-theory-1st-edition-james-c-robinson/
https://ebookname.com/product/photoelectrochemical-materials-and-
energy-conversion-processes-1st-edition-richard-c-alkire/
https://ebookname.com/product/mindfulness-1st-edition-heidegger/
https://ebookname.com/product/where-to-retire-7th-edition-globe-
pequot-press/
Within the Frame The Journey of Photographic Vision 1st
Edition 2009 David Duchemin
https://ebookname.com/product/within-the-frame-the-journey-of-
photographic-vision-1st-edition-2009-david-duchemin/
Download from Wow! eBook <www.wowebook.com>
Allen B. Downey
Think Python
Think Python
by Allen B. Downey
Copyright © 2012 Allen Downey. All rights reserved.
Printed in the United States of America.
Published by O’Reilly Media, Inc., 1005 Gravenstein Highway North, Sebastopol, CA 95472.
O’Reilly books may be purchased for educational, business, or sales promotional use. Online editions are
also available for most titles (http://my.safaribooksonline.com). For more information, contact our corporate/
institutional sales department: 800-998-9938 or corporate@oreilly.com.
Editors: Mike Loukides and Meghan Blanchette Proofreader: Stacie Arellano
Production Editor: Rachel Steely Cover Designer: Karen Montgomery
Interior Designer: David Futato
Illustrators: Robert Romano and Rebecca Demarest
Nutshell Handbook, the Nutshell Handbook logo, and the O’Reilly logo are registered trademarks of O’Reilly
Media, Inc. Think Python, the image of a Carolina Parrot, and related trade dress are trademarks of O’Reilly
Media, Inc.
Many of the designations used by manufacturers and sellers to distinguish their products are claimed as
trademarks. Where those designations appear in this book, and O’Reilly Media, Inc., was aware of a trade
mark claim, the designations have been printed in caps or initial caps.
Think Python is available under the Creative Commons Attribution-NonCommercial 3.0 Unported License.
The author maintains an online version at http://thinkpython.com/thinkpython.pdf.
While every precaution has been taken in the preparation of this book, the publisher and authors assume
no responsibility for errors or omissions, or for damages resulting from the use of the information contained
herein.
ISBN: 978-1-449-33072-9
[LSI]
Table of Contents
Preface. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xi
iii
Exercises 21
3. Functions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
Function Calls 23
Type Conversion Functions 23
Math Functions 24
Composition 25
Adding New Functions 25
Definitions and Uses 27
Flow of Execution 27
Parameters and Arguments 28
Variables and Parameters Are Local 29
Stack Diagrams 30
Fruitful Functions and Void Functions 31
Why Functions? 32
Importing with from 32
Debugging 33
Glossary 33
Exercises 35
iv | Table of Contents
Recursion 53
Stack Diagrams for Recursive Functions 54
Infinite Recursion 55
Keyboard Input 55
Debugging 56
Glossary 57
Exercises 58
6. Fruitful Functions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61
Return Values 61
Incremental Development 62
Composition 64
Boolean Functions 65
More Recursion 66
Leap of Faith 68
One More Example 68
Checking Types 69
Debugging 70
Glossary 71
Exercises 72
7. Iteration. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75
Multiple Assignment 75
Updating Variables 76
The while Statement 76
break 78
Square Roots 79
Algorithms 80
Debugging 81
Glossary 81
Exercises 82
8. Strings. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85
A String Is a Sequence 85
len 86
Traversal with a for Loop 86
String Slices 87
Strings Are Immutable 88
Searching 89
Looping and Counting 89
String Methods 90
The in Operator 91
Table of Contents | v
String Comparison 92
Debugging 92
Glossary 94
Exercises 95
vi | Table of Contents
Exercises 133
A. Debugging. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 233
C. Lumpy. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 255
Index. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 265
Table of Contents | ix
Preface
xi
My first version was rough, but it worked. Students did the reading, and they understood
enough that I could spend class time on the hard topics, the interesting topics and (most
important) letting the students practice.
I released the book under the GNU Free Documentation License, which allows users
to copy, modify, and distribute the book.
What happened next is the cool part. Jeff Elkner, a high school teacher in Virginia,
adopted my book and translated it into Python. He sent me a copy of his translation,
and I had the unusual experience of learning Python by reading my own book. As Green
Tea Press, I published the first Python version in 2001.
In 2003 I started teaching at Olin College and I got to teach Python for the first time.
The contrast with Java was striking. Students struggled less, learned more, worked on
more interesting projects, and generally had a lot more fun.
Over the last nine years I continued to develop the book, correcting errors, improving
some of the examples and adding material, especially exercises.
The result is this book, now with the less grandiose title Think Python. Some of the
changes are:
• I added a section about debugging at the end of each chapter. These sections present
general techniques for finding and avoiding bugs, and warnings about Python
pitfalls.
• I added more exercises, ranging from short tests of understanding to a few sub
stantial projects. And I wrote solutions for most of them.
• I added a series of case studies—longer examples with exercises, solutions, and
discussion. Some are based on Swampy, a suite of Python programs I wrote for use
in my classes. Swampy, code examples, and some solutions are available from http://
thinkpython.com.
• I expanded the discussion of program development plans and basic design patterns.
• I added appendices about debugging, analysis of algorithms, and UML diagrams
with Lumpy.
I hope you enjoy working with this book, and that it helps you learn to program and
think, at least a little bit, like a computer scientist.
—Allen B. Downey
Needham, MA
xii | Preface
Acknowledgments
Many thanks to Jeff Elkner, who translated my Java book into Python, which got this
project started and introduced me to what has turned out to be my favorite language.
Thanks also to Chris Meyers, who contributed several sections to How to Think Like a
Computer Scientist.
Thanks to the Free Software Foundation for developing the GNU Free Documentation
License, which helped make my collaboration with Jeff and Chris possible, and Creative
Commons for the license I am using now.
Thanks to the editors at Lulu who worked on How to Think Like a Computer Scientist.
Thanks to all the students who worked with earlier versions of this book and all the
contributors (listed below) who sent in corrections and suggestions.
Contributor List
More than 100 sharp-eyed and thoughtful readers have sent in suggestions and correc
tions over the past few years. Their contributions, and enthusiasm for this project, have
been a huge help. If you have a suggestion or correction, please send email to feed
back@thinkpython.com. If I make a change based on your feedback, I will add you to
the contributor list (unless you ask to be omitted).
If you include at least part of the sentence the error appears in, that makes it easy for
me to search. Page and section numbers are fine, too, but not quite as easy to work with.
Thanks!
• Lloyd Hugh Allen sent in a correction to Section 8.4.
• Yvon Boulianne sent in a correction of a semantic error in Chapter 5.
• Fred Bremmer submitted a correction in Section 2.1.
• Jonah Cohen wrote the Perl scripts to convert the LaTeX source for this book into beautiful HTML.
• Michael Conlon sent in a grammar correction in Chapter 2 and an improvement in style in Chapter
1, and he initiated discussion on the technical aspects of interpreters.
• Benoit Girard sent in a correction to a humorous mistake in Section 5.6.
• Courtney Gleason and Katherine Smith wrote horsebet.py, which was used as a case study in an
earlier version of the book. Their program can now be found on the website.
• Lee Harr submitted more corrections than we have room to list here, and indeed he should be listed
as one of the principal editors of the text.
• James Kaylin is a student using the text. He has submitted numerous corrections.
Preface | xiii
• David Kershaw fixed the broken catTwice function in Section 3.10.
• Eddie Lam has sent in numerous corrections to Chapters 1, 2, and 3. He also fixed the Makefile so
that it creates an index the first time it is run and helped us set up a versioning scheme.
• Man-Yong Lee sent in a correction to the example code in Section 2.4.
• David Mayo pointed out that the word “unconsciously” in Chapter 1 needed to be changed to
“subconsciously.”
• Chris McAloon sent in several corrections to Sections 3.9 and 3.10.
• Matthew J. Moelter has been a long-time contributor who sent in numerous corrections and sug
gestions to the book.
• Simon Dicon Montford reported a missing function definition and several typos in Chapter 3. He
also found errors in the increment function in Chapter 13.
• John Ouzts corrected the definition of “return value” in Chapter 3.
• Kevin Parks sent in valuable comments and suggestions as to how to improve the distribution of the
book.
• David Pool sent in a typo in the glossary of Chapter 1, as well as kind words of encouragement.
• Michael Schmitt sent in a correction to the chapter on files and exceptions.
• Robin Shaw pointed out an error in Section 13.1, where the printTime function was used in an
example without being defined.
• Paul Sleigh found an error in Chapter 7 and a bug in Jonah Cohen’s Perl script that generates HTML
from LaTeX.
• Craig T. Snydal is testing the text in a course at Drew University. He has contributed several valuable
suggestions and corrections.
• Ian Thomas and his students are using the text in a programming course. They are the first ones to
test the chapters in the latter half of the book, and they have made numerous corrections and
suggestions.
• Keith Verheyden sent in a correction in Chapter 3.
• Peter Winstanley let us know about a longstanding error in our Latin in Chapter 3.
• Chris Wrobel made corrections to the code in the chapter on file I/O and exceptions.
• Moshe Zadka has made invaluable contributions to this project. In addition to writing the first draft
of the chapter on Dictionaries, he provided continual guidance in the early stages of the book.
• Christoph Zwerschke sent several corrections and pedagogic suggestions, and explained the differ
ence between gleich and selbe.
• James Mayer sent us a whole slew of spelling and typographical errors, including two in the con
tributor list.
• Hayden McAfee caught a potentially confusing inconsistency between two examples.
xiv | Preface
• Angel Arnal is part of an international team of translators working on the Spanish version of the
text. He has also found several errors in the English version.
• Tauhidul Hoque and Lex Berezhny created the illustrations in Chapter 1 and improved many of the
other illustrations.
• Dr. Michele Alzetta caught an error in Chapter 8 and sent some interesting pedagogic comments
and suggestions about Fibonacci and Old Maid.
• Andy Mitchell caught a typo in Chapter 1 and a broken example in Chapter 2.
• Kalin Harvey suggested a clarification in Chapter 7 and caught some typos.
• Christopher P. Smith caught several typos and helped us update the book for Python 2.2.
• David Hutchins caught a typo in the Foreword.
• Gregor Lingl is teaching Python at a high school in Vienna, Austria. He is working on a German
translation of the book, and he caught a couple of bad errors in Chapter 5.
• Julie Peters caught a typo in the Preface.
• Florin Oprina sent in an improvement in makeTime, a correction in printTime, and a nice typo.
• D. J. Webre suggested a clarification in Chapter 3.
• Ken found a fistful of errors in Chapters 8, 9 and 11.
• Ivo Wever caught a typo in Chapter 5 and suggested a clarification in Chapter 3.
• Curtis Yanko suggested a clarification in Chapter 2.
• Ben Logan sent in a number of typos and problems with translating the book into HTML.
• Jason Armstrong saw the missing word in Chapter 2.
• Louis Cordier noticed a spot in Chapter 16 where the code didn’t match the text.
• Brian Cain suggested several clarifications in Chapters 2 and 3.
• Rob Black sent in a passel of corrections, including some changes for Python 2.2.
• Jean-Philippe Rey at Ecole Centrale Paris sent a number of patches, including some updates for
Python 2.2 and other thoughtful improvements.
• Jason Mader at George Washington University made a number of useful suggestions and corrections.
• Jan Gundtofte-Bruun reminded us that “a error” is an error.
• Abel David and Alexis Dinno reminded us that the plural of “matrix” is “matrices”, not “matrixes.”
This error was in the book for years, but two readers with the same initials reported it on the same
day. Weird.
• Charles Thayer encouraged us to get rid of the semi-colons we had put at the ends of some statements
and to clean up our use of “argument” and “parameter.”
• Roger Sperberg pointed out a twisted piece of logic in Chapter 3.
• Sam Bull pointed out a confusing paragraph in Chapter 2.
Preface | xv
• Andrew Cheung pointed out two instances of “use before def.”
• C. Corey Capel spotted the missing word in the Third Theorem of Debugging and a typo in
Chapter 4.
• Alessandra helped clear up some Turtle confusion.
• Wim Champagne found a brain-o in a dictionary example.
• Douglas Wright pointed out a problem with floor division in arc.
• Jared Spindor found some jetsam at the end of a sentence.
• Lin Peiheng sent a number of very helpful suggestions.
• Ray Hagtvedt sent in two errors and a not-quite-error.
• Torsten Hübsch pointed out an inconsistency in Swampy.
• Inga Petuhhov corrected an example in Chapter 14.
• Arne Babenhauserheide sent several helpful corrections.
• Mark E. Casida is is good at spotting repeated words.
• Scott Tyler filled in a that was missing. And then sent in a heap of corrections.
• Gordon Shephard sent in several corrections, all in separate emails.
• Andrew Turner spotted an error in Chapter 8.
• Adam Hobart fixed a problem with floor division in arc.
• Daryl Hammond and Sarah Zimmerman pointed out that I served up math.pi too early. And Zim
spotted a typo.
• George Sass found a bug in a Debugging section.
• Brian Bingham suggested Exercise 11-10.
• Leah Engelbert-Fenton pointed out that I used tuple as a variable name, contrary to my own advice.
And then found a bunch of typos and a “use before def.”
• Joe Funke spotted a typo.
• Chao-chao Chen found an inconsistency in the Fibonacci example.
• Jeff Paine knows the difference between space and spam.
• Lubos Pintes sent in a typo.
• Gregg Lind and Abigail Heithoff suggested Exercise 14-4.
• Max Hailperin has sent in a number of corrections and suggestions. Max is one of the authors of the
extraordinary Concrete Abstractions, which you might want to read when you are done with this
book.
• Chotipat Pornavalai found an error in an error message.
• Stanislaw Antol sent a list of very helpful suggestions.
xvi | Preface
• Eric Pashman sent a number of corrections for Chapters 4–11.
• Miguel Azevedo found some typos.
• Jianhua Liu sent in a long list of corrections.
• Nick King found a missing word.
• Martin Zuther sent a long list of suggestions.
• Adam Zimmerman found an inconsistency in my instance of an “instance” and several other errors.
• Ratnakar Tiwari suggested a footnote explaining degenerate triangles.
• Anurag Goel suggested another solution for is_abecedarian and sent some additional corrections.
And he knows how to spell Jane Austen.
• Kelli Kratzer spotted one of the typos.
• Mark Griffiths pointed out a confusing example in Chapter 3.
• Roydan Ongie found an error in my Newton’s method.
• Patryk Wolowiec helped me with a problem in the HTML version.
• Mark Chonofsky told me about a new keyword in Python 3.
• Russell Coleman helped me with my geometry.
• Wei Huang spotted several typographical errors.
• Karen Barber spotted the the oldest typo in the book.
• Nam Nguyen found a typo and pointed out that I used the Decorator pattern but didn’t mention it
by name.
• Stéphane Morin sent in several corrections and suggestions.
• Paul Stoop corrected a typo in uses_only.
• Eric Bronner pointed out a confusion in the discussion of the order of operations.
• Alexandros Gezerlis set a new standard for the number and quality of suggestions he submitted. We
are deeply grateful!
• Gray Thomas knows his right from his left.
• Giovanni Escobar Sosa sent a long list of corrections and suggestions.
• Alix Etienne fixed one of the URLs.
• Kuang He found a typo.
• Daniel Neilson corrected an error about the order of operations.
• Will McGinnis pointed out that polyline was defined differently in two places.
• Swarup Sahoo spotted a missing semi-colon.
• Frank Hecker pointed out an exercise that was under-specified, and some broken links.
• Animesh B helped me clean up a confusing example.
Preface | xvii
• Martin Caspersen found two round-off errors.
• Gregor Ulm sent several corrections and suggestions.
xviii | Preface
CHAPTER 1
The Way of the Program
The goal of this book is to teach you to think like a computer scientist. This way of
thinking combines some of the best features of mathematics, engineering, and natural
science. Like mathematicians, computer scientists use formal languages to denote ideas
(specifically computations). Like engineers, they design things, assembling components
into systems and evaluating tradeoffs among alternatives. Like scientists, they observe
the behavior of complex systems, form hypotheses, and test predictions.
The single most important skill for a computer scientist is problem solving. Problem
solving means the ability to formulate problems, think creatively about solutions, and
express a solution clearly and accurately. As it turns out, the process of learning to
program is an excellent opportunity to practice problem-solving skills. That’s why this
chapter is called, “The way of the program.”
On one level, you will be learning to program, a useful skill by itself. On another level,
you will use programming as a means to an end. As we go along, that end will become
clearer.
1
The advantages are enormous. First, it is much easier to program in a high-level lan
guage. Programs written in a high-level language take less time to write, they are shorter
and easier to read, and they are more likely to be correct. Second, high-level languages
are portable, meaning that they can run on different kinds of computers with few or no
modifications. Low-level programs can run on only one kind of computer and have to
be rewritten to run on another.
Due to these advantages, almost all programs are written in high-level languages. Low-
level languages are used only for a few specialized applications.
Two kinds of programs process high-level languages into low-level languages:
interpreters and compilers. An interpreter reads a high-level program and executes it,
meaning that it does what the program says. It processes the program a little at a time,
alternately reading lines and performing computations. Figure 1-1 shows the structure
of an interpreter.
Figure 1-1. An interpreter processes the program a little at a time, alternately reading lines
and performing computations.
A compiler reads the program and translates it completely before the program starts
running. In this context, the high-level program is called the source code, and the
translated program is called the object code or the executable. Once a program is com
piled, you can execute it repeatedly without further translation. Figure 1-2 shows the
structure of a compiler.
Figure 1-2. A compiler translates source code into object code, which is run by a hardware
executor.
The chevron, >>>, is the prompt the interpreter uses to indicate that it is ready. If you
type 1 + 1, the interpreter replies 2.
Alternatively, you can store code in a file and use the interpreter to execute the contents
of the file, which is called a script. By convention, Python scripts have names that end
with .py.
To execute the script, you have to tell the interpreter the name of the file. If you have a
script named dinsdale.py and you are working in a UNIX command window, you type
python dinsdale.py. In other development environments, the details of executing
scripts are different. You can find instructions for your environment at the Python web
site http://python.org.
Working in interactive mode is convenient for testing small pieces of code because you
can type and execute them immediately. But for anything more than a few lines, you
should save your code as a script so you can modify and execute it in the future.
What Is a Program?
A program is a sequence of instructions that specifies how to perform a computation.
The computation might be something mathematical, such as solving a system of equa
tions or finding the roots of a polynomial, but it can also be a symbolic computation,
such as searching and replacing text in a document or (strangely enough) compiling a
program.
The details look different in different languages, but a few basic instructions appear in
just about every language:
input:
Get data from the keyboard, a file, or some other device.
output:
Display data on the screen or send data to a file or other device.
math:
Perform basic mathematical operations like addition and multiplication.
conditional execution:
Check for certain conditions and execute the appropriate code.
repetition:
Perform some action repeatedly, usually with some variation.
What Is a Program? | 3
Believe it or not, that’s pretty much all there is to it. Every program you’ve ever used, no
matter how complicated, is made up of instructions that look pretty much like these. So
you can think of programming as the process of breaking a large, complex task into
smaller and smaller subtasks until the subtasks are simple enough to be performed with
one of these basic instructions.
That may be a little vague, but we will come back to this topic when we talk about
algorithms.
What Is Debugging?
Programming is error-prone. For whimsical reasons, programming errors are called
bugs and the process of tracking them down is called debugging.
Three kinds of errors can occur in a program: syntax errors, runtime errors, and se
mantic errors. It is useful to distinguish between them in order to track them down more
quickly.
Syntax Errors
Python can only execute a program if the syntax is correct; otherwise, the interpreter
displays an error message. Syntax refers to the structure of a program and the rules
about that structure.For example, parentheses have to come in matching pairs, so
(1 + 2) is legal, but 8) is a syntax error.
In English readers can tolerate most syntax errors, which is why we can read the poetry
of e. e. cummings without spewing error messages. Python is not so forgiving. If there
is a single syntax error anywhere in your program, Python will display an error message
and quit, and you will not be able to run your program. During the first few weeks of
your programming career, you will probably spend a lot of time tracking down syntax
errors. As you gain experience, you will make fewer errors and find them faster.
Runtime Errors
The second type of error is a runtime error, so called because the error does not appear
until after the program has started running. These errors are also called exceptions
because they usually indicate that something exceptional (and bad) has happened.
Runtime errors are rare in the simple programs you will see in the first few chapters, so
it might be a while before you encounter one.
Experimental Debugging
One of the most important skills you will acquire is debugging. Although it can be
frustrating, debugging is one of the most intellectually rich, challenging, and interesting
parts of programming.
In some ways, debugging is like detective work. You are confronted with clues, and you
have to infer the processes and events that led to the results you see.
Debugging is also like an experimental science. Once you have an idea about what is
going wrong, you modify your program and try again. If your hypothesis was correct,
then you can predict the result of the modification, and you take a step closer to a
working program. If your hypothesis was wrong, you have to come up with a new one.
As Sherlock Holmes pointed out, “When you have eliminated the impossible, whatever
remains, however improbable, must be the truth.” (A. Conan Doyle, The Sign of Four)
For some people, programming and debugging are the same thing. That is, program
ming is the process of gradually debugging a program until it does what you want. The
idea is that you should start with a program that does something and make small mod
ifications, debugging them as you go, so that you always have a working program.
For example, Linux is an operating system that contains thousands of lines of code, but
it started out as a simple program Linus Torvalds used to explore the Intel 80386 chip.
According to Larry Greenfield, “One of Linus’s earlier projects was a program that would
switch between printing AAAA and BBBB. This later evolved to Linux.” (The Linux
Users’ Guide Beta Version 1).
Later chapters will make more suggestions about debugging and other programming
practices.
Semantic Errors | 5
Another Random Document on
Scribd Without Any Related Topics
("Καὶ σφι τριξὰ ἐξέυρήματα ἐγένετο—τὰ σημήϊα ποιὲεσθαι.")
2. Calliope, § 74.
("Ὀ δέτερος τῶν λόγων—ἐπίοημον ἄγκυραν.")
TACITUS.
(The Annals.—Lib. 1.)
1. ("Tum redire paulatim—in sedes referunt."—Cap. 28.)
"They relinquished the guard of the gates; and the Eagles and
other Ensigns, which in the beginning of the Tumult they had
thrown together, were now restored each to its distinct station."
"The ship wherein Europa was conveyed from Phœnicia into Crete
had a bull for its flag, and Jupiter for its tutelary deity. The Bœotian
ships had for their tutelar god Cadmus, represented with a dragon in
his hand, because he was the founder of Thebes, the principal city of
Bœotia. The name of the ship was usually taken from the flag, as
appears in the following passage of Ovid, where he tells us his ship
received its name from the helmet painted upon it:—
The family tokens (mon) of the Japanese, however, fulfil very nearly
all of the essentials of armory, although considered heraldically they
may appear somewhat peculiar to European eyes. Though perhaps
never forming the entire decoration of a shield, they do appear upon
weapons and armour, and are used most lavishly in the decoration of
clothing, rooms, furniture, and in fact almost every conceivable
object, being employed for decorative purposes in precisely the
same manners and methods that armorial devices are decoratively
made use of in this country. A Japanese of the upper classes always
has his mon in three places upon his kimono, usually at the back just
below the collar and on either sleeve. The Japanese servants also
wear their service badge in much the same manner that in olden
days the badge was worn by the servants of a nobleman. The design
of the service badge occupies the whole available surface of the
back, and is reproduced in a miniature form on each lappel of the
kimono. Unfortunately, like armorial bearings in Europe, but to a far
greater extent, the Japanese mon has been greatly pirated and
abused.
Fig. 1, "Kiku-non-hana-mon," formed from the conventionalised
bloom (hana) of the chrysanthemum, is the mon of the State. It is
formed of sixteen petals arranged in a circle, and connected on the
outer edge by small curves.
Fig. 2, "Kiri-mon," is the personal mon of the Mikado, formed of the
leaves and flower of the Paulowna imperialis, conventionally treated.
Fig. 3, "Awoï-mon," is the mon of the House of Minamoto Tokugawa,
and is composed of three sea leaves (Asarum). The Tokugawa
reigned over the country as Shogune from 1603 until the last
revolution in 1867, before which time the Emperor (the Mikado) was
only nominally the ruler.
Fig. 4 shows the mon of the House of Minamoto Ashikaya, which
from 1336 until 1573 enjoyed the Shogunat.
Fig. 5 shows the second mon of the House of Arina, Toymote, which
is used, however, throughout Japan as a sign of luck.
Fig. 6.— Fig. 7.— Fig. 8.—Lily on
Double eagle Device of the the Bab-al-
on a coin Mameluke Hadid gate at
(drachma) Emir Toka Damascus.
under the Timur,
Orthogide of Governor of
Kaifa Naçr Rahaba, 1350.
Edin Mahmud,
1217.
The Saracens and the Moors, to whom we owe the origin of so many
of our recognised heraldic charges and the derivation of some of our
terms (e.g. "gules," from the Persian gul, and "azure" from the
Persian lazurd) had evidently on their part something more than the
rudiments of armory, as Figs. 6 to 11 will indicate.
One of the best definitions of a coat of arms that I know, though this
is not perfect, requires the twofold qualification that the design must
be hereditary and must be connected with armour. And there can be
no doubt that the theory of armory as we now know it is governed
by those two ideas. The shields and the crests, if any decoration of a
helmet is to be called a crest, of the Greeks and the Romans
undoubtedly come within the one requirement. Also were they
indicative of and perhaps intended to be symbolical of the owner.
They lacked, however, heredity, and we have no proof that the
badges we read of, or the decorations of shield and helmet, were
continuous even during a single lifetime. Certainly as we now
understand the term there must be both continuity of use, if the
arms be impersonal, or heredity if the arms be personal. Likewise
must there be their use as decorations of the implements of warfare.
If we exact these qualifications as essential, armory as a fact and as
a science is a product of later days, and is the evolution from the
idea of tribal badges and tribal means and methods of honour
applied to the decoration of implements of warfare. It is the
conjunction and association of these two distinct ideas to which is
added the no less important idea of heredity. The civilisation of
England before the Conquest has left us no trace of any sort or kind
that the Saxons, the Danes, or the Celts either knew or practised
armory. So that if armory as we know it is to be traced to the period
of the Norman Conquest, we must look for it as an adjunct of the
altered civilisation and the altered law which Duke William brought
into this country. Such evidence as exists is to the contrary, and
there is nothing that can be truly termed armorial in that marvellous
piece of cotemporaneous workmanship known as the Bayeux
tapestry.
Concerning the Bayeux tapestry and the evidence it affords,
Woodward and Burnett's "Treatise on Heraldry," apparently following
Planché's conclusions, remarks: "The evidence afforded by the
famous tapestry preserved in the public library of Bayeux, a series of
views in sewed work representing the invasion and conquest of
England by William the Norman, has been appealed to on both sides
of this controversy, and has certainly an important bearing on the
question of the antiquity of coat-armour. This panorama of seventy-
two scenes is on probable grounds believed to have been the work
of the Conqueror's Queen Matilda and her maidens; though the
French historian Thierry and others ascribe it to the Empress Maud,
daughter of Henry III. The latest authorities suggest the likelihood of
its having been wrought as a decoration for the Cathedral of Bayeux,
when rebuilt by William's uterine brother Odo, Bishop of that See, in
1077. The exact correspondence which has been discovered
between the length of the tapestry and the inner circumference of
the nave of the cathedral greatly favours this supposition. This
remarkable work of art, as carefully drawn in colour in 1818 by Mr.
C. Stothard, is reproduced in the sixth volume of the Vetusta
Monumenta; and more recently an excellent copy of it from autotype
plates has been published by the Arundel Society. Each of its scenes
is accompanied by a Latin description, the whole uniting into a
graphic history of the event commemorated. We see Harold taking
leave of Edward the Confessor; riding to Bosham with his hawk and
hounds; embarking for France; landing there and being captured by
the Count of Ponthieu; redeemed by William of Normandy, and in the
midst of his Court aiding him against Conan, Count of Bretagne;
swearing on the sacred relics to recognise William's claim of
succession to the English throne, and then re-embarking for
England. On his return, we have him recounting the incidents of his
journey to Edward the Confessor, to whose funeral obsequies we are
next introduced. Then we have Harold receiving the crown from the
English people, and ascending the throne; and William, apprised of
what had taken place, consulting with his half-brother Odo about
invading England. The war preparations of the Normans, their
embarkation, their landing, their march to Hastings, and formation
of a camp there, form the subjects of successive scenes; and finally
we have the battle of Hastings, with the death of Harold and the
flight of the English. In this remarkable piece of work we have
figures of more than six hundred persons, and seven hundred
animals, besides thirty-seven buildings, and forty-one ships or boats.
There are of course also numerous shields of warriors, of which
some are round, others kite-shaped, and on some of the latter are
rude figures, of dragons or other imaginary animals, as well as
crosses of different forms, and spots. On one hand it requires little
imagination to find the cross patée and the cross botonnée of
heraldry prefigured on two of these shields. But there are several
fatal objections to regarding these figures as incipient armory,
namely that while the most prominent persons of the time are
depicted, most of them repeatedly, none of these is ever
represented twice as bearing the same device, nor is there one
instance of any resemblance in the rude designs described to the
bearings actually used by the descendants of the persons in
question. If a personage so important and so often depicted as the
Conqueror had borne arms, they could not fail to have had a place in
a nearly contemporary work, and more especially if it proceeded
from the needle of his wife."
Lower, in his "Curiosities of Heraldry," clinches the argument when
he writes: "Nothing but disappointment awaits the curious armorist
who seeks in this venerable memorial the pale, the bend, and other
early elements of arms. As these would have been much more easily
imitated with the needle than the grotesque figures before alluded
to, we may safely conclude that personal arms had not yet been
introduced." The "Treatise on Heraldry" proceeds: "The Second
Crusade took place in 1147; and in Montfaucon's plates of the no
longer extant windows of the Abbey of St. Denis, representing that
historical episode, there is not a trace of an armorial ensign on any
of the shields. That window was probably executed at a date when
the memory of that event was fresh; but in Montfaucon's time, the
beginning of the eighteenth century, the Science héroïque was
matter of such moment in France that it is not to be believed that
the armorial figures on the shields, had there been any, would have
been left out."
Surely, if anywhere, we might have expected to have found evidence
of armory, if it had then existed, in the Bayeux Tapestry. Neither do
the seals nor the coins of the period produce a shield of arms. Nor
amongst the host of records and documents which have been
preserved to us do we find any reference to armorial bearings. The
intense value and estimation attached to arms in the fourteenth and
fifteenth centuries, which has steadily though slowly declined since
that period, would lead one to suppose that had arms existed as we
know them at an earlier period, we should have found some definite
record of them in the older chronicles. There are no such references,
and no coat of arms in use at a later date can be relegated to the
Conquest or any anterior period. Of arms, as we know them, there
are isolated examples in the early part of the twelfth century,
perhaps also at the end of the eleventh. At the period of the Third
Crusade (1189) they were in actual existence as hereditary
decorations of weapons of warfare.
Luckily, for the purposes of deductive reasoning, human nature
remains much the same throughout the ages, and, dislike it as we
may, vanity now and vanity in olden days was a great lever in the
determination of human actions. A noticeable result of civilisation is
the effort to suppress any sign of natural emotion; and if the human
race at the present day is not unmoved by a desire to render its
appearance attractive, we may rest very certainly assured that in the
twelfth and thirteenth centuries this motive was even more
pronounced, and still yet more pronounced at a more remote
distance of time. Given an opportunity of ornament, there you will
find ornament and decoration. The ancient Britons, like the Maories
of to-day, found their opportunities restricted to their skins. The
Maories tattoo themselves in intricate patterns, the ancient Britons
used woad, though history is silent as to whether they were content
with flat colour or gave their preference to patterns. It is
unnecessary to trace the art of decoration through embroidery upon
clothes, but there is no doubt that as soon as shields came into use
they were painted and decorated, though I hesitate to follow
practically the whole of heraldic writers in the statement that it was
the necessity for distinction in battle which accounted for the
decoration of shields. Shields were painted and decorated, and
helmets were adorned with all sorts of ornament, long before the
closed helmet made it impossible to recognise a man by his facial
peculiarities and distinctions. We have then this underlying principle
of vanity, with its concomitant result of personal decoration and
adornment. We have the relics of savagery which caused a man to
be nicknamed from some animal. The conjunction of the two
produces the effort to apply the opportunity for decoration and the
vanity of the animal nickname to each other.
We are fast approaching armory. In those days every man fought,
and his weapons were the most cherished of his personal
possessions. The sword his father fought with, the shield his father
carried, the banner his father followed would naturally be amongst
the articles a son would be most eager to possess. Herein are the
rudiments of the idea of heredity in armory; and the science of
armory as we know it begins to slowly evolve itself from that point,
for the son would naturally take a pride in upholding the fame which
had clustered round the pictured signs and emblems under which his
father had warred.
Another element then appeared which exercised a vast influence
upon armory. Europe rang from end to end with the call to the
Crusades. We may or we may not understand the fanaticism which
gripped the whole of the Christian world and sent it forth to fight the
Saracens. That has little to do with it. The result was the collection
together in a comparatively restricted space of all that was best and
noblest amongst the human race at that time. And the spirit of
emulation caused nation to vie with nation, and individual with
individual in the performance of illustrious feats of honour. War was
elevated to the dignity of a sacred duty, and the implements of
warfare rose in estimation. It is easy to understand the glory
therefore that attached to arms, and the slow evolution which I have
been endeavouring to indicate became a concrete fact, and it is due
to the Crusades that the origin of armory as we now know it was
practically coeval throughout Europe, and also that a large
proportion of the charges and terms and rules of heraldry are
identical in all European countries.
The next dominating influence was the introduction, in the early part
of the thirteenth century, of the closed helmet. This hid the face of
the wearer from his followers and necessitated some means by
which the latter could identify the man under whom they served.
What more natural than that they should identify him by the
decoration of his shield and the ornaments of his helmet, and by the
coat or surcoat which he wore over his coat of mail?
This surcoat had afforded another opportunity of decoration, and it
had been decorated with the same signs that the wearer had
painted on his shield, hence the term "coat of arms." This textile
coat was in itself a product of the Crusades. The Crusaders went in
their metal armour from the cooler atmospheres of Europe to the
intolerable heat of the East. The surcoat and the lambrequin alike
protected the metal armour and the metal helmet from the rays of
the sun and the resulting discomfort to the wearer, and were also
found very effective as a preventative of the rust resulting from rain
and damp upon the metal. By the time that the closed helmet had
developed the necessity of distinction and the identification of a man
with the pictured signs he wore or carried, the evolution of armory
into the science we know was practically complete.
CHAPTER II
THE STATUS AND THE MEANING OF A COAT OF ARMS IN GREAT
BRITAIN
It would be foolish and misleading to assert that the possession of a
coat of arms at the present date has anything approaching the
dignity which attached to it in the days of long ago; but one must
trace this through the centuries which have passed in order to form
a true estimate of it, and also to properly appreciate a coat of arms
at the present time. It is necessary to go back to the Norman
Conquest and the broad dividing lines of social life in order to obtain
a correct knowledge. The Saxons had no armory, though they had a
very perfect civilisation. This civilisation William the Conqueror upset,
introducing in its place the system of feudal tenure with which he
had been familiar on the Continent. Briefly, this feudal system may
be described as the partition of the land amongst the barons, earls,
and others, in return for which, according to the land they held, they
accepted a liability of military service for themselves and so many
followers. These barons and earls in their turn sublet the land on
terms advantageous to themselves, but nevertheless requiring from
those to whom they sublet the same military service which the King
had exacted from themselves proportionate with the extent of the
sublet lands. Other subdivisions took place, but always with the
same liability of military service, until we come to those actually
holding and using the lands, enjoying them subject to the liability of
military service attached to those particular lands. Every man who
held land under these conditions—and it was impossible to hold land
without them—was of the upper class. He was nobilis or known, and
of a rank distinct, apart, and absolutely separate from the remainder
of the population, who were at one time actually serfs, and for long
enough afterwards, of no higher social position than they had
enjoyed in their period of servitude. This wide distinction between
the upper and lower classes, which existed from one end of Europe
to the other, was the very root and foundation of armory. It cannot
be too greatly insisted upon. There were two qualitative terms,
"gentle" and "simple," which were applied to the upper and lower
classes respectively. Though now becoming archaic and obsolete,
the terms "gentle" and "simple" are still occasionally to be met with
used in that original sense; and the two adjectives "gentle" and
"simple," in the everyday meanings of the words, are derived from,
and are a later growth from the original usage with the meaning of
the upper and lower classes; because the quality of being gentle was
supposed to exist in that class of life referred to as gentle, whilst the
quality of simplicity was supposed to be an attribute of the lower
class. The word gentle is derived from the Latin word gens (gentilis),
meaning a man, because those were men who were not serfs. Serfs
and slaves were nothing accounted of. The word "gentleman" is a
derivative of the word gentle, and a gentleman was a member of the
gentle or upper class, and gentle qualities were so termed because
they were the qualities supposed to belong to the gentle class. A
man was not a gentleman, even in those days, because he
happened to possess personal qualities usually associated with the
gentle class; a man was a gentleman if he belonged to the gentle or
upper class and not otherwise, so that "gentleman" was an identical
term for one to whom the word nobilis was applied, both being
names for members of the upper class. To all intents and purposes
at that date there was no middle class at all. The kingdom was the
land; and the trading community who dwelt in the towns were of
little account save as milch kine for the purposes of taxation. The
social position conceded to them by the upper class was little, if any,
more than was conceded to the lower classes, whose life and
liberties were held very cheaply. Briefly to sum up, therefore, there
were but the two classes in existence, of which the upper class were
those who held the land, who had military obligations, and who
were noble, or in other words gentle. Therefore all who held land
were gentlemen; because they held land they had to lead their
servants and followers into battle, and they themselves were
personally responsible for the appearance of so many followers,
when the King summoned them to war. Now we have seen in the
previous chapter that arms became necessary to the leader that his
followers might distinguish him in battle. Consequently all who held
land having, because of that land, to be responsible for followers in
battle, found it necessary to use arms. The corollary is therefore
evident, that all who held lands of the King were gentlemen or
noble, and used arms; and as a consequence all who possessed
arms were gentlemen, for they would not need or use arms, nor was
their armour of a character upon which they could display arms,
unless they were leaders. The leaders, we have seen, were the land-
owning or upper class; therefore every one who had arms was a
gentleman, and every gentleman had arms. But the status of
gentlemen existed before there were coats of arms, and the later
inseparable connection between the two was an evolution.
The preposterous prostitution of the word gentleman in these latter
days is due to the almost universal attribute of human nature which
declines to admit itself as of other than gentle rank; and in the eager
desire to write itself gentleman, it has deliberately accepted and
ordained a meaning to the word which it did not formerly possess,
and has attributed to it and allowed it only such a definition as
would enable almost anybody to be included within its ranks.
The word gentleman nowadays has become meaningless as a word
in an ordinary vocabulary; and to use the word with its original and
true meaning, it is necessary to now consider it as purely a technical
term. We are so accustomed to employ the word nowadays in its
unrestricted usage that we are apt to overlook the fact that such a
usage is comparatively modern. The following extract from "The
Right to Bear Arms" will prove that its real meaning was understood
and was decided by law so late as the seventeenth century to be "a
man entitled to bear arms":—
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.
ebookname.com