0% found this document useful (0 votes)
23 views

Buy ebook Think Python 1st Edition Allen B Downey cheap price

Downey

Uploaded by

socopraviniy
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
23 views

Buy ebook Think Python 1st Edition Allen B Downey cheap price

Downey

Uploaded by

socopraviniy
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 40

Get ebook downloads in full at ebookmeta.

com

Think Python 1st Edition Allen B Downey

https://ebookmeta.com/product/think-python-1st-edition-
allen-b-downey/

OR CLICK BUTTON

DOWNLOAD NOW

Explore and download more ebook at https://ebookmeta.com


Recommended digital products (PDF, EPUB, MOBI) that
you can download immediately if you are interested.

Think Python 2nd Edition Allen B Downey

https://ebookmeta.com/product/think-python-2nd-edition-allen-b-downey/

ebookmeta.com

Think Python How to Think Like a Computer Scientist Allen


B Downey

https://ebookmeta.com/product/think-python-how-to-think-like-a-
computer-scientist-allen-b-downey/

ebookmeta.com

Think Python How to Think Like a Computer Scientist 2nd


Edition Allen B Downey

https://ebookmeta.com/product/think-python-how-to-think-like-a-
computer-scientist-2nd-edition-allen-b-downey/

ebookmeta.com

Potato Kitchen From Soil to Table More Than 70 Inspiring


Recipes 1st Edition Manuela Ruther

https://ebookmeta.com/product/potato-kitchen-from-soil-to-table-more-
than-70-inspiring-recipes-1st-edition-manuela-ruther/

ebookmeta.com
Understanding Semiconductors 1st Edition Corey Richard

https://ebookmeta.com/product/understanding-semiconductors-1st-
edition-corey-richard/

ebookmeta.com

The Opaque Experience Literature and Disenchantment


Iberian and Latin American Studies The Arts Literature and
Identity Florencia Garramuno
https://ebookmeta.com/product/the-opaque-experience-literature-and-
disenchantment-iberian-and-latin-american-studies-the-arts-literature-
and-identity-florencia-garramuno/
ebookmeta.com

Science of the Soul in Ibn Sina's Pointers and Reminders:


A Philological Study (English and Arabic Edition) Michael
A. Rapoport
https://ebookmeta.com/product/science-of-the-soul-in-ibn-sinas-
pointers-and-reminders-a-philological-study-english-and-arabic-
edition-michael-a-rapoport/
ebookmeta.com

Diabetes Meal Planning & Nutrition For Dummies, 2nd


Edition Simon Poole

https://ebookmeta.com/product/diabetes-meal-planning-nutrition-for-
dummies-2nd-edition-simon-poole/

ebookmeta.com

Exhale (Fresh Hell Book 2) 1st Edition Charity Parkerson

https://ebookmeta.com/product/exhale-fresh-hell-book-2-1st-edition-
charity-parkerson/

ebookmeta.com
Conceiving Desire in Lyly and Shakespeare Metaphor
Cognition and Eros Edinburgh Critical Studies in
Shakespeare and Philosophy 1st Edition Gillian Knoll
https://ebookmeta.com/product/conceiving-desire-in-lyly-and-
shakespeare-metaphor-cognition-and-eros-edinburgh-critical-studies-in-
shakespeare-and-philosophy-1st-edition-gillian-knoll/
ebookmeta.com
Think Python

Allen B. Downey
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 [email protected].
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

August 2012: First Edition

Revision History for the First Edition:

2012-08-03 First release

See http://oreilly.com/catalog/errata.csp?isbn=9781449330729 for release details.

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

1. The Way of the Program. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1


The Python Programming Language 1
What Is a Program? 3
What Is Debugging? 4
Syntax Errors 4
Runtime Errors 4
Semantic Errors 5
Experimental Debugging 5
Formal and Natural Languages 6
The First Program 7
Debugging 8
Glossary 9
Exercises 11

2. Variables, Expressions, and Statements. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13


Values and Types 13
Variables 14
Variable Names and Keywords 15
Operators and Operands 16
Expressions and Statements 16
Interactive Mode and Script Mode 17
Order of Operations 18
String Operations 18
Comments 19
Debugging 19
Glossary 20

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

4. Case Study: Interface Design. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37


TurtleWorld 37
Simple Repetition 38
Exercises 39
Encapsulation 40
Generalization 41
Interface Design 42
Refactoring 43
A Development Plan 44
Docstring 44
Debugging 45
Glossary 45
Exercises 46

5. Conditionals and Recursion. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49


Modulus Operator 49
Boolean Expressions 49
Logical Operators 50
Conditional Execution 50
Alternative Execution 51
Chained Conditionals 51
Nested Conditionals 52

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

9. Case Study: Word Play. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97


Reading Word Lists 97
Exercises 98
Search 99
Looping with Indices 100
Debugging 102
Glossary 102
Exercises 103

10. Lists. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105


A List Is a Sequence 105
Lists Are Mutable 106
Traversing a List 107
List Operations 107
List Slices 108
List Methods 108
Map, Filter, and Reduce 109
Deleting Elements 111
Lists and Strings 112
Objects and Values 112
Aliasing 113
List Arguments 114
Debugging 116
Glossary 117
Exercises 118

11. Dictionaries. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 121


Dictionary as a Set of Counters 123
Looping and Dictionaries 124
Reverse Lookup 125
Dictionaries and Lists 126
Memos 128
Global Variables 129
Long Integers 130
Debugging 131
Glossary 132

vi | Table of Contents
Exercises 133

12. Tuples. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 135


Tuples Are Immutable 135
Tuple Assignment 136
Tuples as Return Values 137
Variable-Length Argument Tuples 137
Lists and Tuples 138
Dictionaries and Tuples 139
Comparing Tuples 141
Sequences of Sequences 142
Debugging 143
Glossary 144
Exercises 144

13. Case Study: Data Structure Selection. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 147


Word Frequency Analysis 147
Random Numbers 148
Word Histogram 149
Most Common Words 150
Optional Parameters 151
Dictionary Subtraction 151
Random Words 152
Markov Analysis 153
Data Structures 154
Debugging 156
Glossary 157
Exercises 158

14. Files. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 159


Persistence 159
Reading and Writing 159
Format Operator 160
Filenames and Paths 161
Catching Exceptions 162
Databases 163
Pickling 164
Pipes 165
Writing Modules 166
Debugging 167
Glossary 168

Table of Contents | vii


Exercises 169

15. Classes and Objects. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 171


User-Defined Types 171
Attributes 172
Rectangles 173
Instances as Return Values 174
Objects Are Mutable 175
Copying 176
Debugging 177
Glossary 178
Exercises 178

16. Classes and Functions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 181


Time 181
Pure Functions 182
Modifiers 183
Prototyping Versus Planning 184
Debugging 185
Glossary 186
Exercises 187

17. Classes and Methods. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 189


Object-Oriented Features 189
Printing Objects 190
Another Example 191
A More Complicated Example 192
The init Method 192
The __str__ Method 193
Operator Overloading 194
Type-Based Dispatch 194
Polymorphism 196
Debugging 197
Interface and Implementation 197
Glossary 198
Exercises 199

18. Inheritance. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 201


Card Objects 201
Class Attributes 202
Comparing Cards 204
Decks 205

viii | Table of Contents


Printing the Deck 205
Add, Remove, Shuffle, and Sort 206
Inheritance 207
Class Diagrams 209
Debugging 210
Data Encapsulation 211
Glossary 212
Exercises 213

19. Case Study: Tkinter. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 217


GUI 217
Buttons and Callbacks 218
Canvas Widgets 219
Coordinate Sequences 220
More Widgets 221
Packing Widgets 222
Menus and Callables 224
Binding 225
Debugging 227
Glossary 229
Exercises 230

A. Debugging. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 233

B. Analysis of Algorithms. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 243

C. Lumpy. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 255

Index. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 265

Table of Contents | ix
Preface

The Strange History of This Book


In January 1999 I was preparing to teach an introductory programming class in Java. I
had taught it three times and I was getting frustrated. The failure rate in the class was
too high and, even for students who succeeded, the overall level of achievement was too
low.
One of the problems I saw was the books. They were too big, with too much unnecessary
detail about Java, and not enough high-level guidance about how to program. And they
all suffered from the trap door effect: they would start out easy, proceed gradually, and
then somewhere around Chapter 5 the bottom would fall out. The students would get
too much new material, too fast, and I would spend the rest of the semester picking up
the pieces.
Two weeks before the first day of classes, I decided to write my own book. My goals
were:
• Keep it short. It is better for students to read 10 pages than not read 50 pages.
• Be careful with vocabulary. I tried to minimize the jargon and define each term at
first use.
• Build gradually. To avoid trap doors, I took the most difficult topics and split them
into a series of small steps.
• Focus on programming, not the programming language. I included the minimum
useful subset of Java and left out the rest.

I needed a title, so on a whim I chose How to Think Like a Computer Scientist.

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
[email protected]. 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
Other documents randomly have
different content
from the complicated compounds found in the soil, or take it from the
air only by aid of certain Bacteria.
Certain plants manufacture lime and metallic oxides with which to
harden the protective armour they wear. Many others generate nitric
acid, carbonic acid and ammonia for use in their interior laboratories.
Roots nearly always secrete a fluid which aids in the absorption of
minerals from the earth. It is so powerful that quartz, flint and
limestone are often scratched and corroded by its action. Above and
below ground, plants are active chemical laboratories.
The differences of taste, smell and colour which characterize
leaves, blossoms and fruits are due to the presence of various
organic compounds. These are largely volatile oils which are more
complex than the substances involved in the simpler life processes.
The slow or rapid evaporation of these oils influences the strength
and character of an odour. When a flower or fruit passes through
infinite gradations of colour, we can give no adequate account of the
chemical changes involved. All we can do is to observe and to note.
Sometimes infusions of iron sulphate or other chemicals in the soil
darken the hues of flowers. Gardeners profit by this fact in the
cultivation of certain varieties of Hortensia.
The chemical activities of plants are of incalculable value to man.
They change air, water and mineral salts into forms easily
assimilable by the human system. Eliminate all the vegetable life
from this planet, and the animals, including man, would perish in a
few months. Man has also learned to make abundant use of plant
substances for innumerable purposes. Potash is an example of how
the plants come to our aid in furnishing us a valuable chemical. It is
extracted from wood, Seaweed and Banana stalks. These plants
have discovered a way of getting it out of its well-nigh insoluble earth
combinations with silica. If it had not been for certain industrious sea
plants, man would probably never have been aware of the important
chemical twins, bromine and iodine, so important in photography.
These plants patiently filter them out of sea water where they exist in
microscopic quantities, and build them into their bodies. Beer is
possible because germinating grains transform amylum or plant
starch into sugar. We find ripe fruits palatable because their acids
change into sugar under the influence of sunlight.
Man seems to have outstripped the plants in the use of light, heat,
electricity, and other physical forces, but the plants have more
engineers among them than we imagine. In the fact that man has
just learned to extract nitrogen from the air by the agency of
electrical discharges, lies the probable explanation of how the plants
have been doing the same thing for years. It is believed that the
minute electrical discharges continually going on between the
different air strata make small quantities of nitrogen assimilable for
the plants. The micro-organisms which also furnish nitrogenous
material to the plants may get nitrogen from the air in the same way.
It is quite certain that the plants are affected by the chemical state of
the atmosphere.
Everyone knows what an important part light plays in plant
physiology, but the fact that certain plants produce their own lights,
while generally known, is not universally understood. The Austrian
naturalist, Heller, was the first to demonstrate that the glowing of
decayed wood at night is caused by emanations of light from Fungus
growing in the cavities. A similiar organism called Luminous
Peridineas (sometimes classed as an animal) is responsible for the
phosphorescence of the ocean and the night lights of many flowers.
About three hundred species of Bacteria and fifteen species of
Fungus are recognized to be luminous. The dead leaves of the
tropical Banibusa, Nephelium and Aglaia often glow at night with the
light of these tiny creatures. Ordinary dead Oak and Beech leaves
are luminous, sometimes shining in spots, but frequently glowing
throughout with a soft, white, steady light. These miniature
incandescent lights often shine for days, weeks and months, and
with abundant nutriment at hand, sometimes for years. The light is
slight in intensity, but uniformly steady and white, green or blue-
green in colour. It is strong enough to enable the plants on which the
Fungus grows to photograph themselves by long exposure to
sensitized plates. The fungus light has also been used to influence
the heliotropic movements of plant seedlings. In fact, a colony of
Fungus has sometimes been placed in an electric light bulb and
made thus to serve as an illuminant.
No matter from what angle we study the plants, we find that they
are extremely scientific. They conduct themselves and all their
activities in a way to always get the best results. They show
knowledge and acquaintance with all of Nature’s laws, and they have
learned to apply many of them with startling success.
MODERN NATURE WORSHIPPERS
CHAPTER X
Religion in the Plant World

“Denied in heaven the soul he held on earth.”


—Byron
In a sense, the entire plant world is a beautiful and expressive
worship of a bountiful and beneficent Creator. No creed which does
not deny God will fail to see the silent but reverent adoration
exhibited by His handiwork. Every tree which raises its brave crest
toward the heavens, every flower which greets the warming sunlight
with a smile, is a testimony to the omnipotence of divine law. Fully
explain the wonders of a single blade of Grass, and you have solved
the mysteries which underlie the universe.
Primitive peoples, who are always closely attuned to natural
influences, early discerned the divine thread which runs through all
plantdom. In their incessant search for God, they did not overlook
His manifestations in the plants and flowers. Along with fire, water,
stars, sun, moon, animals, birds and graven images, our wood-
roving ancestors ascribed supernatural attributes to many trees and
flowers. In various places and at various times, many different plants
have been idolized as the material substance of an ethereal or
spiritual being. Certain plant growths have been repeatedly
designated as sacred, and even in the present day, untutored races
have many plant superstitions. Tree worship was common among
the Celts and Teutons. The present day Christmas tree is a relic of
primitive tree veneration. Even the American Indians worshiped trees
at times. Man has been groping for God all through the ages. His
tendency has been to deify those elements and things which he did
not understand or which contained mystery. As soon as he became
acquainted with the causes of these mysteries, the supernatural
collapsed into the natural and he went searching after new wonders
to call God.
From the beginning of literature, the bards of every land have sung
to and of the flowers; the prophets have used them as instruments
for their sooth-saying; the believer in resurrection has cited them to
prove a final resurrection for the souls of men; the reincarnationists
have claimed in them a great evidence of the reincarnation of the
soul; the atheist has tried to show through them the validity of his
belief; hero and conqueror have found in them their crowns of glory
and the poet has made them the theme of his pen. Yet the flowers
bloom today much as they did on the hillsides of Greece and
Babylon, and man, with all his century-accumulated wisdom, seems
but to have seen the outer edge of their real lives.
The superstitious veneration of various flowers is an ancient and
peculiarly charming expression of man’s innate appreciation of the
beautiful. He who condemns as idolaters the flower-worshippers of
ancient ages may well look upon himself with critical eyes. Which is
the better: to pay tribute to the Creator through the adoration of his
beautiful floral children or make cold, glittering gold the ultimate
though unacknowledged goal of this earthly life?
It is interesting to notice, in reviewing the annals of flower-worship,
that the most fervent and frequent examples are found in tropical
countries. This is due, no doubt, to the luxuriance of vegetation in the
hot countries, and the fact that, in most cases, flowers are in bloom
there all the year around. Even one trained in a more rigid faith is
tempted to strange reverence when he suddenly comes upon a
great, glowing Orchid, squatting like some beautiful animal on the
shaggy trunk of an aged tree. A Hindu is quite excusable when he
becomes raptly worshipful while paddling through a floating sea of
Lotus-Flowers.
In heathen mythology, “every flower was the emblem of a god;
every tree the abode of a nymph.” Paradise, itself, was a kind of
“nemorous temple or sacred grove” planted by God himself. The
patriarchal groves which are prominent throughout Biblical history
were probably planted as living memorials of the Garden of Eden,
the first grove and man’s first abode.
Sacred flowers were common among the Greeks. The Anemone,
Poppy and Violet were dedicated to Venus. To Diana belonged “all
flowers growing in untrodden dells and shady nooks,
uncontaminated by the tread of man.” The Narcissus and Maiden-
Hair Fern were under the special protection of Proserpina and to
Ceres belonged the Willow. The Pink was Jove’s flower, while Juno
claimed the Lily, Crocus and Asphodel.
The life of Christ flings a bright and illuminating ray of light over the
whole vegetable world. Trees and flowers which have heretofore
been associated with various heathen rites now become connected
with holier names and are frequently made a part of the crucifixion
itself. Hosts of flowers are dedicated to the Virgin Mary, particularly
white ones, which are taken to be emblematic of her purity. Christian
worshippers even went to the classic Juno and Diana, to the
Scandinavian Freyja and Bertha, to obtain flowers to dedicate to her.
The Passion Flower was often taken to represent various incidents
connected with the crucifixion.
Though the Rose and the Lily are the blossoms which are most
frequently associated with the Virgin, particularly in paintings, there
is an endless list of other flowers of low and high degree which are
either named after her or thought to be under her influence.
Orchids are called “Our Lady’s Slipper.” Maiden-Hair is “Virgin’s
Hair.” The Thyme, Woodroof and Groundsel plants are reputed to
have formed the Virgin’s bed. Among fruits the Strawberry and the
Molluka Bean have been set aside for her worship.
The “Rose of Jericho” is made famous by the Bible. Popular
tradition states that it first blossomed at Christ’s birth, closed at His
crucifixion and reopened at His resurrection. The legend of the rose-
coloured Sainfoin is especially interesting. One of the flowers
happened to be among the grasses and herbs lodged in the manger
of the Christ child. At the presence of that holy form, it suddenly
opened its blossoms to form a wreath for His head.
A more gruesome tale relates that the Wood-Sorrel, Spotted
Persicaria, Arum, Purple Orchid and Red Anemone owe their dark-
stained blossoms to the blood which trickled from the Cross.
Among the many theories regarding the identity of the wood of the
Cross, the one about the Mistletoe is especially fanciful. The
Mistletoe is alleged to have been originally a full-sized tree but
because of its ignoble part in the great Christian tragedy, it was
reduced to its present parasitical form.
Every saint in the Catholic calendar has his own particular flower,
either because of some incident in his life with which it was
connected or because of arbitrary dedication. Care has been taken
to pick flowers which are in bloom at the time of the festival of the
saint which they represent. In this way, the flowers of the field make
a living, religious time-piece.
Among the individual sacred flowers, Orchids and Lotus-Blossoms
have probably been known and reverenced as much as any. There
is small wonder that sentiment approaching veneration should exist
toward the Orchids. Their singular beauty and fragrance have
compelled the admiration of all historic peoples. The primitive
Mexicans hold them in very great esteem. The Lotus-Flower,
portrayed through all the ages, on papyrus, paper, silk, stone, and
wood, has a world-wide sanctity. The ancient Egyptians worshipped
the Lotus in connection with the mysteries of Isis and Osiris. The
sculptural remains of the Nile abound with the sacred plant in every
stage of its development, the flowers and fruit being represented with
utmost accuracy. The Brahmans regarded it as divine and the
Hindus used it to decorate their temples and lay on their religious
altars. The Chinese also called it sacred. Brahma, at his birth, is said
to have come forth from the Lotus. Buddha and other eastern deities,
including the Chinese god Pazza, are reported to have first appeared
floating on its leaves.
Sir William Jones was one time dining on the banks of the
Ganges. Desiring to examine the sacred Lotus-Flower, he
despatched some of his people to procure a specimen. When it was
brought, his Indian attendants immediately fell on their faces in
adoration.
The Yellow Narcissus is a famous fabled flower which originally
came from Palestine. Mahomet once said: “Whoever possesses two
loaves of bread, let him trade one for a blossom of Narcissus, for
bread is nourishment for the body, but the Narcissus for the soul.”
The birth of the Narcissus is narrated thus: In Sussexshire, England,
the good St. Leonhard once battled with a dragon for three whole
days. Before he was able to slay the monster, the doughty warrior
was wounded with consequent loss of blood. God could not bear to
see the life fluid of this holy man spilled heedlessly, so transformed
each drop, as it fell, into a Narcissus.
“Consider the Lilies of the field, how they grow; they toil not,
neither do they spin; and yet I say unto you that even Solomon in all
his glory was not arrayed like one of these.” This is a great tribute to
the Lily and it has been similarly praised throughout all literature.
About this lovely flower hang myriads of sacred legends and such
titles as the “symbol of purity,” the “soul of beauty” and “the symbol
of peace.” In the lore of the Greeks and the Orientals, this matchless
flower was hailed with the Rose as the “Queen of Heaven.” The
Venerable Bede called it the most worthy symbol of the Virgin. He
said that its pure white petals represent her undefiled body and the
golden stamens her radiant soul shining with god-like light. Many old
paintings of the Virgin show her with a vase of Lilies by her side.
The Rose is the universal symbol of royalty. In Greek mythology, it
was the favourite flower of Aphrodite and was represented as
springing from the blood of Adonis. Through all Norse and German
mythology is repeated reference to the “regal beauty” and “queenly
mien” of the Rose. In northern lands, the Rose was under the special
protection of the fairies, dwarves, and elves.
The “Balm of Gilead” is a well-known sacred plant (Balsamum
Judaicum) written of by Pliny, Strabo and Justin and grown in many
parts of the East. It is said to have been first brought from Arabia by
the Queen of Sheba as a gift to Solomon.
St. John’s Wort (Hypericum Perforatum) was dedicated to St. John
because its phosphorescent glow was remindful of the Biblical
reference to him as a “bright and shining light.” Some European
peasants still believe that, if gathered and worn on St. John’s Eve, it
has the power of bringing good luck and success.
The Greeks and Romans used Verbena extensively in their
religious ceremonies, principally because of its wonderful perfume.
The Romans called it “the sacred herb” and regarded it as an aid in
divinations and omens. On New Year’s Day, it was sent to friends as
a token of greeting. The Roman generals wore a sprig in their
pockets as a protection against bodily injury.
The Soma or Moon-Plant of India (Asclepias Acida) is a climbing
vine with milky juice which is said to confer immortality upon its
admirers.
Pomegranate was long reverenced by the Persians and Jews as
the forbidden fruit of the Garden of Eden.
The Indian plant Basil for many centuries has been held in good
repute by the Hindus, having been made sacred to Vishnu.
Mahomet pronounced Henna, the Egyptian Privet, “chief of the
flowers of this world and the next.” Wormwood was dedicated to the
goddess Iris.
If there are many plants which man’s adoration has made
religious, there are almost an equal number which his suspicion and
perversity have branded irreligious. A famous plant of this kind is the
Enchanter’s Nightshade which has long been celebrated in the
mysteries of witchcraft. Perhaps its usual place of growth in old
graveyards among decaying bones and mouldering coffins has much
to do with the sinister superstitions and legends connected with it.
The Belladonna is another plant whose name is often associated
with black magic.
To this day many Danes believe that the Elder is eternally cursed.
Children who sleep in beds containing Elder wood continually
complain of having their feet tickled and their legs pulled. To carry a
cane of Elder is to invite attacks of slander. Women who have Elder
wood in their houses will never be married. It is the elves who dwell
in the Elder who are supposed to work all this mischief.
Plants often rise superior to the curse which men place upon
them. Probably every well-known plant, sometime in its history, has
had attributed to it both good and evil. The deity of one nation may
become the demon of another.
Plant worship holds a more prominent place in the world today
than one would at first thought imagine, and it is not altogether
confined to uncultured peoples. Dr. George Birdwood tells of
remarkable instances of modern flower worship he saw in Bombay.
In describing the Victoria Gardens, he says: “Presently, a true
Persian, in flowing robes of blue, and on his head his sheep-skin hat,
‘black, glossy, curl’d, the fleece of Kar-kal’, would saunter in, and
stand and meditate over every flower he saw, and always, as if half
in vision. And when the vision was fulfilled, and the flower he was
seeking found, he would spread his mat and sit before it until the
setting of the sun, then fold up his mat again and night after night,
until that particular flower faded away, he would return to it, and bring
his friends in ever-increasing troupes to it, and sit and play the guitar
or lute before it, and they would altogether pray there, and after
praying still sit before it, sipping sherbet, and talking the most
hilarious and shocking scandal late into the moonlight; and so again
and again every evening until the flower died. Sometimes, by way of
grand finalé the whole company would suddenly rise before the
flower and serenade it together, with an ode from Hafiz, and then
depart.”
CHAPTER XI
Plant Mythology

“I’ll seek a four-leaved clover


In all the fairy dells,
And if I find the charmed leaf,
Oh, how I’ll weave my spells.”
Every Plant is surrounded by a halo of human thought. If one is
able to discern that halo, he finds a new and fascinating interest
attaching itself to each herb and flower. The most humble of them
become fortune-tellers, luck-bringers, and talismen against evil, as
well as dwelling-places of fairies, elves, imps, and other ethereal
mischief-makers.
In the childhood of humanity, the earth was a very romantic place.
In addition to the familiar human inhabitants, there were whole races
of supernatural and invisible beings which wielded great influence
over the every-day world of affairs. Every plant was considered good
or evil, according to the character of the spirits which it was believed
to harbour.
People of this practical age are inclined to look upon these stories
with contemptuous intolerance. “We have outgrown such baby-talk,”
they say, and forthwith relegate whole kingdoms of elfin hosts to their
children’s nurseries, or possibly refuse them their homes entirely. But
to a few discerning minds, these idle dreams of a romantic past offer
a most refreshing contrast to present-day utilitarianism.
The airy fancies of our forefathers should have a larger share in
our thought today. A single flower myth contains more beauty and
enduring appeal than a hundred steel mills. We must go back to the
youth of the race,—to the time of Shakespeare, Milton, and gentle
Ben Jonson,—for our noblest literature. In those days, men actually
believed in fairies, goblins, and all the rest, and were probably better
for having done so. We, with our broader intellectual outlook, can
congratulate ourselves that we have advanced beyond such things,
but still appreciate their spirit and their beauty.
In studying plant mythology, it is interesting to notice that certain
traditions and legends are to be found in all parts of the world and in
many widely separated localities, forming, as it were, the ground-
work of a great universal system of folklore. This would suggest that
plant myths are founded mainly on true and inherent facts rather
than on passing fancies. Almost all the nations have chosen the
Rose for the queen of the floral court, and therefore the most fitting
symbol of love. The White Lily has purity written on its spotless
petals, and could never stand for anything else, anywhere. The
Poppy is a brilliant, sensuous flower, quite suggestive of the narcotic
excesses which its opium induces. Many extravagant plant beliefs of
the past had their foundation in medicine. In the Middle Ages,
quacks and charlatans used herbs having curative powers to exhort
money from the masses. A few of the correctives were of real value,
but there were thousands of out-and-out deceptions. Even so
redolent and simple a thing as the common Onion was sometimes
suspended in a room in the belief that it would draw all troublesome
maladies out of the inmates. The first herbalists were priests, but
gradually their art passed into the hands of professional outsiders,
where it suffered greater and greater abuse.
One ancient dogma taught that each plant possessed the power of
healing one particular disease, made known by some outward sign
or similiarity. Thus bright-eyed flowers were good for those with
failing sight; red blossoms of all kinds would arrest nose-bleed;
Turmeric, a very yellow dye, cured jaundice; plants with long, tubular
flowers were excellent specifics for throat troubles.
Many of these medicinal superstitions linger among the more
simple of the earth’s inhabitants today. Dutch and English
countrymen still believe that a Potato carried in the pocket is a sort of
protective charm against rheumatism. In Ohio, the farmers
sometimes wear a string of Job’s Tears seeds in an effort to cure
goitre. In New England, the same magic charm is used to help
babies through the troublesome period of teething.
The devil and his evil spirits have always wielded a large influence
over certain members of the plant kingdom. In Scotland, up until the
seventeenth century, it was customary to allow a small section of
each farm to lie untilled and uncropped as a peace offering to Satan.
In certain English counties, children of today will not pick
Blackberries after a certain date, believing that the Evil One has
trampled them and made them poisonous to humans. German
peasants, without batting an eye, will tell you that the devil, in one
form or another, has the regular habit of stealing portions of their
crops.
Of plants that are dedicated to Satan, or more properly, which he
has appropriated, there are many hundreds. Toadstools, because of
their miraculously fast growth and fantastic shape, have always been
associated with the kingdom of evil. It is not quite so apparent why
other more beautiful plants are also handed over to Satan, though a
reason can usually be found. The most alluring and gorgeous
flowers are quite apt to be poisonous.
In old Bohemia, the Belladonna was a favourite of the devil. He
could be enticed from it on Walpurgis Night by letting loose a black
hen, after which he ran. In Russia, people shun the Sow-Thistle as a
devil-plant. Some Germans believe that evil spirits lurk in Lettuce
beds. To the same people, the Herban is the “Devil’s Eye.” Many
nationalities are quite sure that the Herb-Bennett, when kept in a
house, takes its owners out from under the devil’s influence. Thistle
is often used for the same purpose. The Greeks used to place a
Laurel bough over their doors to ward off evil. There is an English
Fungus called Lycoperdon, or Puff-Ball, which produces a mass of
dusty spores not unlike snuff. The annoyance experienced by people
in the vicinity of the bursting pods has led to the plant being called
“Devil’s Snuff-Box.” Children use it for various amusing pranks.
Closely allied to the devil-plants are the witch-plants, vegetable
favourites of his human emissaries. The Elder is supposed to be a
frequent meeting-place of these sinister hags; under its branches
they bury their satanic offspring.
The witches employ the deadly Night-Shade in their vile
concoctions. It is reputed to spring from the foam of the vicious,
many-headed dog which guards the infernal regions. The Vervain
and the Rue are also ingredients. The fact that the former was at one
time sacred to Thor, and was also used in the rituals of the Druids, is
a possible explanation of its evil name. Rue as a narcotic capable of
producing hallucinations, is most naturally a witch’s plant. Strange to
say, both of these plants are sometimes used as charms against
witches. The Romans used the Vervain in casting lots, telling
fortunes, and foreshadowing national events. Many other plants,
ordinarily harmless, become the possessors of evil charms when
gathered under certain circumstances. Thus, Shakespeare speaks of
“root of hemlock digg’d i’ the dark,” and “slips of yew sliver’d in the
moon’s eclipse,” as being cast into the bubbling pot.
The Fox Glove is “Witches’ Bell,” and is used by them to decorate
their fingers. They employ the large Ragwort as a steed for their
midnight journeys. In Ireland it is known as “Fairies’ Horse.” It is said
that witches use Fern seed to make themselves invisible. In
Germany they employ the Luck Flower for the same purpose. The
Sea Poppy and the Moonwart (Botrychium Lunaria) are also
numbered among the witch-plants. To the latter is also given the
power of opening locks.
In England, Pimpernel, Herb-Paris and Cyclamen are protections
against witches. In Germany and many other continental countries,
the St. John’s Wort is their enemy and exposer.
The fairies have appropriated many flowers for their especial use.
Despite the disbelief of latter days, to some people elfland still
extends around the globe, and defies all the laws of chemistry and
physics. It is still fairy midnight trippings which form those mysterious
circles or depressions often to be noticed on the dewy sward of early
morning. When the peasant girls of England go out into the
meadows to beautify their complexions with applications of May dew,
they always leave these mystic circles severely alone, for fear of
offending the fays.
Midnight is the fairy magic hour. At the trumpet call of the Harebell,
they gallop to their meeting-places mounted on blades of Grass or
on Cabbage leaves. Sometimes they assemble to the tolling of the
Wood-Sorrel or “Fairy Bell”. For more extended migrations, they
travel in Nuts. They usually dress in green and provide themselves
with mantles of Gossamer. The Irish ones use Fox-Glove blossoms
to cover their hands. In infancy, the fays are cradled in Tulips and
throughout life, they use the Cowslip as a drinking cup, and seek
shelter of the Wood-Anemone in wet weather.
In some localities, it is believed that the fairies create the Toad-
Stools. They are also reputed to gather colours from the sunset
clouds, and with tiny but accurate brushes cover flower petals with
their delicate tints. Fairies seldom reveal themselves to men, but the
lucky possessor of a four-leafed Clover is sometimes privileged to
see them.
From time immemorial, men and maidens in love have sought the
aid of their floral friends. Which of us is there who has not gone to
the Daisy in some heart perplexity of youth, and made its petals say,
“She loves me; She loves me not,” as we pulled them off one by
one? An older and less known superstition says that an Apple seed
placed on a hot stove will hop towards one’s future mate.
In England, the Marigold is used for various love divinations, but in
Germany it is carefully excluded from affairs of the heart. In that
latter country the Star-Flower and the Dandelion are popular in such
cases. There was a time when Peas were much in demand for
sentimental forecasts. On opening a pod, the number of green
spheres discovered had a special significance. The dwarves were
supposed to be especially fond of Peas. Even the prosaic Onion has
at times been used to explain the mysteries of the divine emotion.
The Rose, most superb of flowers, has been extolled through all
ages as the symbol of love. Incidentally, it is the national flower of
England. The Scotch have a pretty ballad legend about Fair
Margaret and Sweet William. The beautiful love of these two young
people never realized itself in marriage. They both met an untimely
death and were buried on either side of the neighbouring church.
Soon there sprang up a climbing Rose vine from the grave of each,
and meeting on the gable of the church, the lovers entwined in the
lasting embrace which had been denied in life. Red Roses, because
of their colour, have sometimes been supposed to have a relation to
human blood. The medieval girl used to bury a few drops of her
blood under a Rosebush in the hope that this action would bring her
ruddy cheeks. The Romans used the Rose as the symbol of love for
the dead. They placed it extensively on their tombs.
In the past, there have arisen rumours of plants of wondrous
properties which have been the mere inventions of glory-seeking
travelers. Sir John Mandeville was a famous offender who even
issued reports of trees which produced live animals in their fruits.
The old Greeks used to decorate their tombs with Parsley. When a
person was dangerously ill, it was often said, “He has need now of
nothing but Parsley.”
The humble Bean has at times been afforded superstitious
reverence. It is said that Pythagoras forbade his disciples to eat it.
The anxiety to secure good crops has led to many superstitious
practices. In the pagan days of Germany and likewise in Rome, an
image was carried around each field in order to insure its fertility.
After the introduction of Christianity, the image of a saint was
substituted for the heathen deity, and the practice continued.
Again and again, the Onion, whose name today is only mentioned
with bated breath, crops up among old plant superstitions. Because
of its structure of enveloping sheaths, the Egyptians rightly
considered it a splendid symbol of the universe. In Christian days,
St. Thomas patronized it. Its cousin, the Leek, bears the blossom
which Welshmen still hail as their national flower. It is worn by all
loyal patriots on March first, St. David’s Day.
The Thistle, Scotland’s national flower, was once sacred to Thor.
In those days it was regarded as a safeguard against lightning, from
which it got its colour. Ireland’s Shamrock belongs to the Trefoil
family, and is sometimes called Dutch Clover, though the Wood-
Sorrel is claimed by some to be the true Shamrock. St. Patrick once
used it as a natural symbol of the trinity, through which it became
nationalized.
Superstitions of the four-leafed Clover have lingered in the
imaginations of men almost more than those of any other plant. To
be efficacious in bringing good luck, the little talisman must be found
unawares. If slipped into the shoe of a lover, it will insure his safe
return. The finding of a five-leaved Clover brings bad luck.
Superstition plays its part in the evolution of knowledge, and
speculation is the parent of modern science. Astrologers, reading the
fortunes of nations and individuals in the stars, paved the way for the
great and exact science of astronomy. Studious alchemists in
searching for a cheap way to make gold, laid the foundations of the
profound science of chemistry. In a similar way, the old herbalists,
with their secret potions and mysterious compounds, were the
instigators of the accurate study of medicine, and most important
from our standpoint, were instruments which greatly advanced the
love and growing appreciation of plants and flowers.
CHAPTER XII
Mysticism in the Plant World

“Who passeth by the Rosemarie


And careth not to take the spraye,
For woman’s love no care has he,
Nor shall he though he live for aye.”
One day John G. Allen of Cherry, Arizona, went fishing along a
small tributary of the River Verde. His skill with the rod seeming to
fail him, he decided to make his outing profitable in other directions
by hunting through some neighbouring cliff-dwellings for pottery.
While wandering through those ancient and curious abodes, he
accidentally discovered a section of wall which looked as though it
might have been built to close a former opening. Careful
investigation revealed the truth of this surmise, for, with a little
perseverance, he broke through and removed enough stone to admit
his body into a small room or recess, which contained some pottery
and household utensils of extreme age.
In one corner of this prehistoric place, Mr. Allen discovered a few
Corn cobs and about a dozen Squash seeds. More as a joke than
anything else, he planted twelve of the seeds the next spring.
Eleven of them remained insensate to the revivifying influence of
earth, sun and water, but the twelfth took courage and, bursting the
walls which had imprisoned it for hundreds and possibly thousands
of years, sprang up into a hardy, healthy vine, which eventually bore
a huge, green, extremely warty Squash weighing nearly twenty-five
pounds. This vegetable visitor from a shadowy age was named the
“Aztec,” and attained great fame.
There have been other and more striking instances of the
suspended animation which permits plant life to lie quiescent for
countless centuries, ready for an opportune time to resume the
regular cycle of its existence. There are those who are always ready
to cry “fraud,” and conclusively prove these marvels false, but there
is abundant evidence to show that plant embryos can and, in some
cases, do survive long periods of time.
What a lesson lies in such phenomena! The power that can keep
alive and unchanged the cells of a vegetable seed so many
centuries is not likely to allow the soul of a man to perish. What an
argument for immortality! What a breeder of strange and mysterious
thoughts!
There is much mysticism in the plant world. What man does not
understand, he either holds in awe or contempt. The plants are too
often treated with good-humoured derision, but among higher minds,
their unintelligible factors give them a greater fascination—a mystery
and a psychic interest which is very alluring.
The plants seem to be closer in tune with Nature than man. They
place themselves under her direct tutelage, and are extremely
sensitive to her various moods and fancies. They respond to
influences of weather and time with remarkable alacrity. The scarlet
Pimpernel in particular, is an excellent barometer. At the least
indication of rain, it folds its petals together in snug security, and,
contrary to human beings, closes instead of opens the umbrella of its
body. On a rainy day, it never unfolds at all, so eager is it to keep its
petals dry.
“No heart can think, no tongue can tell,
The virtues of the Pimpernell.”
The greatest of all floral barometers is the Weather-Plant or Indian
Licorice (Abrus Precatorius). So keenly sensitive to all atmospheric
conditions is this plant that it may be used to foretell cyclones,
hurricanes, earthquakes, and even volcanic eruptions. Its small,
rose-like leaves are in continual motion, which varies noticeably
under different electrical and magnetic influences. The Austrian
Professor Norwack, working at his Weather-Plant Observatory at
Kew Gardens, London, once used it to predict a disastrous fire-damp
explosion.

You might also like