Python for Teenagers: Learn to Program Like a Superhero! James R Payne instant download
Python for Teenagers: Learn to Program Like a Superhero! James R Payne instant download
https://textbookfull.com/product/python-for-teenagers-learn-to-
program-like-a-superhero-james-r-payne/
https://textbookfull.com/product/python-for-teenagers-learn-to-
program-like-a-superhero-2nd-edition-payne/
https://textbookfull.com/product/learn-to-program-with-
python-3-a-step-by-step-guide-to-programming-irv-kalb/
https://textbookfull.com/product/learn-to-program-with-
python-3-a-step-by-step-guide-to-programming-2nd-edition-irv-
kalb/
https://textbookfull.com/product/learn-raspberry-pi-programming-
with-python-learn-to-program-on-the-worlds-most-popular-tiny-
computer-donat/
Learn Raspberry Pi Programming with Python: Learn to
Program on the World’s Most Popular Tiny Computer, 2nd
Edition Wolfram Donat
https://textbookfull.com/product/learn-raspberry-pi-programming-
with-python-learn-to-program-on-the-worlds-most-popular-tiny-
computer-2nd-edition-wolfram-donat/
https://textbookfull.com/product/a-tour-of-data-science-learn-r-
and-python-in-parallel-nailong-zhang/
https://textbookfull.com/product/teach-your-kids-to-code-a-
parent-friendly-guide-to-python-programming-1st-edition-bryson-
payne/
https://textbookfull.com/product/php-and-algorithmic-thinking-
for-the-complete-beginner-2nd-edition-learn-to-think-like-a-
programmer-bouras/
https://textbookfull.com/product/python-one-liners-write-concise-
eloquent-python-like-a-professional-1st-edition-christian-mayer/
Python
for Teenagers
Learn to Program like a Superhero!
—
James R. Payne
Python for Teenagers
Learn to Program like a Superhero!
James R. Payne
Python for Teenagers: Learn to Program like a Superhero!
James R. Payne
Deerfield Beach, FL, USA
Introduction������������������������������������������������������������������������������������������������������������xix
v
Table of Contents
vi
Table of Contents
viii
Table of Contents
ix
Table of Contents
x
Table of Contents
Index��������������������������������������������������������������������������������������������������������������������� 317
xi
About the Author
James R. Payne was introduced to programming when he was just 10 years old. He
started off hacking text-based games like Lemonade Stand to gain an advantage while
playing and soon started creating his own text-based role-playing games in the style of
Dungeons & Dragons and inspired by his favorite comic books. The enjoyment of those
early days stuck with him, and he continues to be drawn back into the programming
world throughout his career.
Payne is the former Editor-in-Chief/Community Manager of Developer Shed, an
online publication and community consisting of 14 websites and forums dedicated to
programming, web development, and Internet marketing. He’s written over a thousand
articles on coding and marketing, covering virtually every language and platform
available. His first book, Beginning Python (Wrox Press), was published in 2010. In
addition, he has published over 2000 articles covering topics ranging from gaming to
aerospace/aeronautics, and also writes adult horror and young adult fantasy books.
Payne decided to write this book to pass on his love of development in the hopes that
it would inspire future generations to code. You can find Payne on the web by visiting
www.jamesrpayne.com.
xiii
About the Technical Reviewer
Andrea Gavana has been programming Python for almost
16 years, dabbling with other languages since the late
1990s. He graduated from university with a master’s degree
in Chemical Engineering, and he is now a Lead Reservoir
Engineer working for Total in Copenhagen, Denmark.
Andrea enjoys programming at work and for fun, and
he has been involved in multiple open source projects, all
Python-based. One of his favorite hobbies is Python coding,
but he is also fond of cycling, swimming, and cozy dinners
with family and friends.
This is his third book as technical reviewer.
xv
Acknowledgments
This book wouldn’t have been possible without Todd Green, who reached out to me to
write a book and listened to my ideas and, thankfully, chose the one I wanted to write the
most.
Jill Balzano, Coordinating Editor extraordinaire, was invaluable in keeping things
rolling during an incredibly busy time, and without her, this book would never have
come to fruition either.
James Markham and Andrea Gavana found all of my errors and proved to me that,
even at this old age, I still have a lot to learn. Who knew – an old dog can learn new tricks.
Thank you to the entire editorial team at Apress, who were a pleasure to work
with and helped me do what I love to do most: write. And make up stupid comic book
characters.
xvii
Introduction
Who This Book Is For
This book is intended for teenagers looking to program in Python. While that technically
means anyone aged 13 through 18, the truth of the matter is, anyone of any age can (and
should, if I do say so myself!) pick up this book if they want to learn either (a) how to
program in Python, (b) how to program as a beginner, or (c) add Python to their current
skill set.
Above all, if you are holding this book in your hand, intrepid adventurer, then this
book is for you. The future is dependent on young heroes like yourself, eager to learn
the art of coding and go out into the world and safeguard it from nefarious hackers,
dubiously programmed applications, and the rise of artificially intelligent robots!
So whether you are in sixth grade or in college, this book will grant you with super
powers galore. Sure, you won’t be able to see through walls or lift cars over your head
once you finish this book. However, you will be able to speak the language of computers
and create some pretty cool programs.
And what could be better than that?
xix
Introduction
Sometimes a program will need to take a certain action depending upon feedback
from a user or from other influences. This is known as decision making and is the topic
of Chapter 4.
Programming logic and loops – known as iterations, where code can “loop” or repeat
itself based on certain conditions – are covered in Chapter 5.
Chapter 6 is a refresher course of what you have learned up until this point. We will
use all the knowledge we’ve acquired to finish building the first complete version of
Super Hero Generator 3000. By the end, you will be able to randomly create heroes with
unique super powers, names, and battle statistics!
In Chapter 7, we begin to learn more advanced techniques. To be a real coder, you
must learn efficiency and reduce mistakes in your code. That is where modules and
built-in functions come into play. Learn what they are and why they will make your life a
whole lot easier in this exciting chapter!
Chapter 8 looks at even more advanced topics: specifically, we will cover the basics
of object-oriented programming (OOP) and cover objects and classes and define a thing
called polymorphism.
To switch things up a little bit, Chapter 9 will look at some different types of data
structures, including tuples and dictionaries.
Chapter 10 brings us up to speed on how to create – and work with – files inside of
directories.
One of my personal favorite chapters is Chapter 11, which covers a topic that is
near and dear to my heart: Python for Gaming. We will stroll through the world of video
games and learn how to work with video game elements, including sound, animation,
and more!
Learning how to create games that interact with a users actions and making images
move within a game are truly what make games enjoyable. Chapter 12 continues the
topic of gaming and focuses specifically on game animation.
In Chapter 13 – don’t worry, in this case 13 is lucky, for you at least! – we move into
areas of Python we have not yet discussed that do not fit in their own chapter. This
includes how to debug – or find broken code. We also look at advanced modules and
other topics.
Finally, we sum everything up in Chapter 14 and cover a wide range of topics,
including how to find work as a Python programmer, common interview questions, the
future of Python, and career paths, and answer some of the frequently asked questions
(FAQs) about our favorite programming language.
xx
Introduction
So now that we know what we will learn, let’s put on our cape and super hero outfits
and get ready to leap tall buildings – of knowledge.
xxi
Introduction
From there, it was not a far stretch to conceive that we could actually create our
own video games and that is exactly what we did. From complex role-playing games
(RPG) based off of our favorite comic books and Dungeons & Dragons to programs that
would ask our friends a series of questions and then make fun of them based off of their
answers – shenanigans!
While all of that seemed silly at the time, looking back on it I now know that it helped
set the foundation for my love of programming and, to a degree, writing (though I began
writing much earlier than that). Without that summer of programming fun, I would
never have had the wonderful experiences, friends, jobs, and writing opportunities that
have come my way ever since.
And, mostly, I would never have had the fun of programming either.
That is what I am hoping to pass on to you, dear reader: a lifetime love of
programming and opportunities all based off of one thing – the fun and joy of writing
computer programs and writing code.
Sure, programming applications can be a pain in the butt. You will find yourself
banging your head against a keyboard on many nights and yelling at the computer
screen for hours only to find that your program isn’t working because you forgot a
parenthesis () somewhere.
But – once you find that mistake that you or another programmer made – there isn’t
quite anything like that triumphant moment when you realize that you – YOU – are the
greatest coder of all time!
xxii
Introduction
Don’t copy and paste code from this book or any other source (assuming you have a
digital copy). Instead, take the time to type in the code so that you can begin to get a feel
for writing code and, perhaps, commit some of the code to memory through repetition.
Do experiment with code. One of the best ways, I’ve found, to learn how to truly
code is to experiment. If you come across an example in the book, feel free to change the
parameters some and see what happens. The worst that can happen is that you can fail.
The best? That you learn something new!
Don’t be afraid to Google other tutorials and how-tos on Python. This book is
supposed to build a beginner’s foundation, but it does not teach you everything there is
to know – that’s what the sequel is for! If you do decide to look up comparative examples,
be certain to look at the date of the article and the version of Python. If the version does
not match the version we are using in this book (Python 3), odds are your code will not
work and you will find yourself very confused.
Do document your code. We have not covered this topic – yet – but for now, know
that documentation means to leave little comments in blocks, or sections, of your code
that lets you (or another coder in the future) know what you intended to do with a certain
section of code. While Python is a very readable language, the way every programmer
codes is different, and what might be apparent to you is not always apparent to others.
Also, if you have to review your own code at a later date, it will make it easier for you to
remember what, exactly, you were trying to do at 4 a.m. 10 years ago!
Do plan out your code. That is, write down how you want your overall program to
work and then break that down into little sections. Then, take those little sections and
map out what you need to code for each part. This way you will have a roadmap to follow
and won’t just be coding by the seat of your pants.
Finally, do test your code frequently and save your work often. When we
programmers are in the thick of things, we like to carry on, plugging away, for hours at a
time. However, if we don’t stop to test our code and save our files, we risk losing hours of
work and, worse, creating a program with problems that are difficult to trace.
xxiii
CHAPTER 1
Introduction to Computer
Programming and Python
Computer programming – commonly referred to as “coding” by the cool kids – is the
art of creating applications or software. These programs allow us to do everything from
solve simple math problems and watch our favorite YouTube videos (I can’t get enough
of skydiving bulldogs) to destroying hordes of rampant aliens in our favorite video games
and even launching a real-life spaceship into outer space.
I call computer programming an “art” because it is. Anytime you create something,
you are indulging in an art form. Sure, computer code, the words we type into a shell to
create our programs (more on this later!), may not be pretty to look at for the common
person on the street – your code will never see the inside of an art exhibit most likely –
but when a part of your program does what you created it to… there is almost nothing
more magical.
Well, maybe those skydiving bulldogs.
A computer program can come in many shapes and sizes. In addition to an
application that runs on your desktop system or a game that plays on your favorite video
game console, programs also take the form of mobile apps on a cell phone. You can even
find pieces of software that operate things like refrigerators, your mom’s minivan, and
even something as simple as a toaster oven.
And robots. Armies of robots.
But more on that later.
For now, know that a computer program is a set of code, created in a programming
language, that tells a device to carry out a set of instructions.
1
© James R. Payne 2019
J. R. Payne, Python for Teenagers, https://doi.org/10.1007/978-1-4842-4550-7_1
Chapter 1 Introduction to Computer Programming and Python
Python Overview
Python is what is known as a high-level, dynamic, interpreted, object-oriented
programming language. While all of that may sound a bit intimidating, never fear! By
the end of this book, you will be able to impress your friends with sentences much more
daunting than the one above! All that statement really means is that Python is not a
basic machine-level language, and as such, it needs an “interpreter” to “compile” it to
machine language so that the computer can understand what it is you are trying to tell it.
2
Chapter 1 Introduction to Computer Programming and Python
This interpreter takes your code and converts it – or compiles it – into a series of 1s
and 0s that a computer can plainly understand. All of that happens in the background, so
don’t worry if you do not quite understand it just yet.
Python is a relatively new programming language that was created in the late 1980s –
back when your dad had a big funny mustache and your mom listened to bands with
names like Wham! and Poison.
The man that created the language was a computer genius named Guido Van
Rossum, who was bestowed with the fancy, nonsensical title, Benevolent Dictator for
Life. Like technology, programming languages evolve as well, and Python is no different.
It has gone through several versions over the years and is currently known as Python 3.
3
Chapter 1 Introduction to Computer Programming and Python
4
Chapter 1 Introduction to Computer Programming and Python
And those are just a few of the benefits and advantages that Python offers.
• Google: The search engine giant and one day ruler of the galaxy,
Google, has been using Python since its inception, partially because
developers can build programs so quickly with it and also because
the code is easy to maintain.
• Facebook and Instagram: While Python is not the only language used
at these two social media platforms, it is one of their most important
ones. Facebook uses Python, in part, thanks to its extensive libraries.
Instagram, meanwhile, is a firm supporter of one of Python’s main
web frameworks – Django. We cover web frameworks in great detail
later in this book.
5
Chapter 1 Introduction to Computer Programming and Python
• Netflix: If you are a fan of streaming movies, then you are no stranger
to Netflix. The company uses Python primarily for its data-analysis
capabilities and for security purposes – among other areas.
• Video games: Battlefield 2 and Civilization 4 are just two video games
that both rely on Python. Interestingly enough, Civilization uses
Python for, among other things, its artificial intelligence (AI) scripts.
No you dummy. That's some guy flying around in his pajamas. Now get back
to work!
6
Chapter 1 Introduction to Computer Programming and Python
Let’s examine the code a little more closely. The part that says print() is known
as a function, whose job it is to tell the computer to – in this case – print something to
the user’s screen. The text in between the opening and closing parentheses () is the
parameter that we are providing the function. The characters in between the quotation
marks “ ” are known as a string.
Don’t worry if this doesn’t make all the sense in the world just yet – we go over this
topic in great detail in the next chapter. For now, just know that this is what Python code
looks like. Odds are, you were able to tell exactly what this program would do before I
told you; that is just one of the things that make Python so great – its readability!
I nstalling Python
In this section, we are going to learn how to install Python on the various operating
systems. An operating system is a piece of software that lets you interact with a computer.
You are probably familiar with the more popular ones, such as Microsoft Windows (if
you own a PC) and Mac OS X if you own an Apple computer. The version of Python you
install will vary depending upon which one of these your computer uses. In addition, we
will learn how to install Python on Linux and Ubuntu systems as well.
The current version of Python is 3.6.5; by the time you read this book, it may be
higher than that. Whatever the case, click the “Download Python” button under the
Download the Latest Version for Windows header. Optionally, you could scroll down and
download previous versions (just make sure they are version 3.X or higher, as there are
incompatibility issues between versions 2.X and 3.X); however, for the purposes of this
book, it is always best to use version 3.6.5 or later.
An image will appear asking if you would like to save the file. Click “Save File”
(Figure 1-2) and save it to your Desktop or somewhere easily remembered.
Navigate to your Desktop (or the location where you saved the file) and double-click
it. It should appear similar to the image in Figure 1-3.
The installer will launch and will ask you whether you wish to “Install Now” or
“Customize Installation.” For ease, we are going to allow the installer to “Install Now.”
Before you click that button, however, make sure that “Install launcher for all users”
and “Add Python 3.6 to PATH” are both checked. Then click the “Install Now” option
(Figure 1-4).
8
Chapter 1 Introduction to Computer Programming and Python
You may get a pop-up from Windows asking for permission to continue the
installation. If so, allow the program to continue. A new pop-up will appear, showing you
the Setup Progress (Figure 1-5):
9
Chapter 1 Introduction to Computer Programming and Python
Once Setup is complete, you will see a screen like the one below. Click the “Close”
button to complete installation (Figure 1-6).
10
Other documents randomly have
different content
an offence to the orthodox, let them accept it, without resentment,
as a little harmless fun—all art being that.
Having said so much I return to my own difficulty, for it is very hard
to focus H.G. Wells. He has passed through many stages and has
not yet attained the Olympian repose. Artist as he is, he has been
hotly entangled in practical affairs. There are signs in his early books
that he once shared what Richard Jeffries called the "dynamite
disposition,"—even now he knows, in imagination alone, the joy of
black destruction. He has also been, and ceased to be, a Fabian. But
it is plain that he has passed for good and all beyond the emotional
plane of propaganda. He has abandoned working-theories and the
deceptions of the intellect which make the man of action. He has
become at once more practical and more mystical than a party
programme permits one to be. Here is a world where things are
being done—a world of which capital and labor are but one
interpretation. How far can these things and the men who do them
be swept into the service of the race? That is the practical issue in
his mind, and the mystical issue lies in the intensity and quality of
the way in which he feels it.
To see him clearly one has to remember that he is not a synthetic
thinker but a sceptical artist, whose writings are subjective even
when they seem to be the opposite, whose personality is constantly
growing, expanding, changing, correcting itself ("one can lie awake
at night and hear him grow," as Chesterton says), and who believes
moreover that truth is not an absolute thing but a consensus of
conflicting individual experiences, a "common reason" to be wrought
out by constant free discussion and the comparison and interchange
of personal discoveries and ideas. He is not a sociologist, but, so to
say, an artist of society; one of those thinkers who are disturbed by
the absence of right composition in human things, by incompetent
draughtsmanship and the misuse of colors, who see the various
races of men as pigments capable of harmonious blending and the
planet itself as a potential work of art which has been daubed and
distorted by ill-trained apprentices. In Wells this planetary
imagination forms a permanent and consistent mood, but it has the
consistency of a mood and not the consistency of a system of ideas.
And though he springs from socialism and leads to socialism, he can
only be called a socialist in the fashion—to adopt a violently
disparate comparison—that St. Francis can be called a Christian.
That is to say, no vivid, fluctuating human being, no man of genius
can ever be embodied in an institution. He thinks and feels it afresh;
his luminous, contradictory, shifting, evanescent impulses may, on
the whole, ally him with this or that aggregate social view, but they
will not let him be subdued to it. As a living, expanding organism he
will constantly urge the fixed idea to the limit of fluidity. So it is with
Wells. There are times when he seems as whimsical as the wind and
as impossible to photograph as a chameleon.
Just here I should like to give what may be taken as his own view of
capital and labor socialism in relation to the constructive socialism he
himself has at heart. I am putting together certain brief passages
from The Passionate Friends:
These last two sentences really tell the whole story. To pass from
economics to psychology is to pass from Man to men, from society
as a direct object of attack to the individuals who compose it. And
this marks the evolution of Wells the romancer and Wells the
expositor of socialist doctrine into Wells the novelist. It is the
problems of human interaction that occupy him now. But informing
these problems, reaching behind and embracing them, is a general
view of the world which has only become more intimate, more
personal, and more concrete with time.
When, in New Worlds for Old, Wells set himself to explain socialism
as he conceived it, he assumed as his first principle a certain Good
Will in men, an operating will steadily working in life toward
betterment. In other words, he supplemented the ordinary socialist
idea of economic determinism, which may or may not inevitably
bring about order on the industrial plane, with a constructive
purpose, which, in his view, can alone bring about the salvation of
the race. But this Good Will is not a fatality; it exists only by virtue of
remaining a conscious effort. In his experiments in Time and Space
Wells had accustomed himself to seeing that the immense
possibilities of what might be, so far as the universe is concerned,
predetermined things, were, so far as man is concerned, matters of
chance. To human society at least, if not to our planet, the most
unpropitious things are possible in the future; and there is no reason
to suppose that the destiny of the universe, which at every turn cuts
athwart the destiny of every species contained in it, should, left to
itself, work favorably to man.
This notion is in itself quite outside socialism and does not
necessarily lead into socialism. It was Huxley who said that the
world and the universe, society and nature, are demonstrably at
cross purposes, and that man has to pit his microcosm against the
macrocosm. Huxley, in his famous lecture on Ethics and Evolution,
went on from this to a kind of informal and unavowed socialism,
figuring society as a well-tended garden preserved by man's careful
art from the ravages and invasions of that hostile world of chance,
with its gigantic weeds and blind impulsions, which everywhere lies
waiting round about it. Our work, he implied, must be in every way
to minimize for ourselves the elements of chance, to become aware
of our species in a collective sense, battling with nature and
moulding our own future.
I do not suppose that Wells consciously adopted this idea from
Huxley. In itself that would be of little consequence, except so far as
it shows the continuity of thought and the development of socialism
out of science. But Wells was for several years a pupil of Huxley, and
it is reasonably plain that the mood in which he wrote his scientific
romances was strongly impregnated by Huxley's influence. The
sinister, incalculable, capricious, destructive forces outside man are
symbolized, as I have said, by those colliding comets, invading
Martians, and monstrous creatures among which the earlier Wells
moved and had his being; just as the sinister, incalculable, capricious
forces within man which urge him to destruction form so great a
part of his later novels. Most of his heroes (typified in The New
Machiavelli) come to grief through the blind irrational impulsions
within themselves. And he is equally haunted by what he has called
the "Possible Collapse of Civilization." I do not know how much this
is due to an evangelical childhood, in which Time, Death, and
Judgment are always imminent; how much to an overbalancing
study of science at the expense of the humanities; how much to an
overdeveloped sense of the hazard that life is; and how much to
plain facts. But there it is: it has always been a fixed conviction with
Wells that man personal and man social is dancing on a volcano.
Therefore he has come to socialism not by the ordinary course but
by a route obscure and lonely. The sense of possible catastrophe
and collapse, the folly of leaving things to chance, the infinite waste
and peril of committing our affairs to nature rather than to art—
these are some of the negative reasons that have made it impossible
for him to fall in with the non-socialist ideal in human affairs, that
"broadening down from precedent to precedent" which he calls
"muddling through": a doctrine that is wholly compatible with a
world of haphazard motives, accidental fortunes, accidental
management, a democratic individualism that places power in
irresponsible hands and suppresses talents that society cannot afford
to lose, a governmental system that concerns itself with legal and
financial arrangements, experts with no sense of a common
purpose, patriotisms that thrive on international bad feelings, and
that competitive principle which succeeds in the degree in which it
ignores the general welfare—a chaos of private aims, private virtues,
private motives, without any collective human design at all.
In the light of these opposed ideas of society as a thing of Chance
and as a thing of Design, let me run over two or three of the tales of
Wells.
First of all there is the special laissez faire of pure economic
determinism. The Time Machine pictures a possible result of the
Marxian process which has led to an irrevocable division of classes.
The rich, who were, in the old time, in comparison with the poor,
disciplined and united, have long since reached a point where work
and fear are for them things of the past. They occupy the surface of
the earth, and idleness and futility have made them light-headed,
puny, helpless creatures, stirring about and amusing themselves in
the sunlight. The poor, meanwhile, driven underground where they
burrow and tend machinery and provide, have lost all human
semblance and become white, horrible ghoul-like creatures that see
in the dark; at night they swarm out of their holes and feed upon
the creatures of the upper air. The one class has lost all power to
defend itself and the other all pity to spare, and gradually, year after
year, mankind comes to its end.
Then there is the ordinary laissez faire of capitalism, a result of
which is pictured in The Sleeper Awakes. The Sleeper, one recalls,
awakens four generations hence to find himself the master-capitalist,
owner of half the world, and the world is one where capital and
labor have irrevocably destroyed the possibility of a constructive
human scheme. But the responsibility for that future is very
ingeniously placed upon us of the present time; for Graham's
ownership of the world is the outcome of one of those irresponsible
whims that in our day characterize the whole individualistic view of
property. His cousin, having no family to inherit his possessions, has
left the whole in trust for the Sleeper, half in jest, expecting him
never to waken; and in time the trustees of this vested fund have
become the irresponsible bureaucrats of the world. "We were
making the future," says the awakened Sleeper, looking out upon
this monstrous outcome of whim and laissez faire; "and hardly any
of us troubled to think what future we were making."
Consider also The Empire of the Ants, in which Wells has figured a
possible reconquest of man by nature, owing to the greater
collective discipline of at least one non-human species. He imagines
a species of poisonous ants with only a little greater faculty of
organized co-operative intelligence than ordinary ants, which have
terrorized and finally routed several villages of unintelligent and
unorganized Brazilian natives far up the Amazon. The Brazilian
government sends against them an outworn inefficient gunboat, with
an incompetent captain and a muddle-headed crew; and when they
arrive the ants fall upon the only man sent ashore and sting him to
death. The captain repeats over and over, "But what can we do?"
And at last with tremendous decision he fires a gun at them and
retires. The story ends with a report that the ants are swarming all
over the interior of Brazil and that nobody knows how to prevent
them from occupying the whole of South America.
And then there is The History of Mr. Polly. I ignore for the moment
the individual aspect of his case, for Mr. Polly is not merely an
individual—he is an emblem of the whole, he is society in concreto.
We find him at the opening of the book sitting on a stile, suffering
from indigestion and consequently depressed in spirits. It is two
o'clock of a Sunday afternoon, and he has just finished his mid-day
meal. He has eaten cold potatoes, cold pork, Rashdall's mixed
pickles—three gherkins, two onions, a small cauliflower head and
several capers; cold suet pudding, treacle and pale cheese, three
slices of grey bread, and a jug of beer. He hates himself, he hates
his wife, he hates existence. But Mr. Polly's interior, the things that
have gone into it and the emotions that rise out of it, are only typical
of an entire life that has, to quote Macaulay's eulogy of the British
constitution, thought nothing of symmetry and much of
convenience.
Each of the novels of Wells, in one aspect at least, presents the
accidental nature of our world in some one typical case. Love and
Mr. Lewisham shows how in the case of one of those young students
who have, as things are, no chance at all, but who are the natural
builders of a better world, the constructive possibility is crushed by
the primary will to live. At eighteen Mr. Lewisham is an assistant
master at one of those incompetent private-enterprise schools which
for Wells (as also for Matthew Arnold) epitomize our haphazard
civilization. He has a "future"—the Schema which he pins to his
bedroom wall promises unimaginable achievements. He marries, and
you feel that he should marry and that he has married the right
person. But then with interests divided he has to find money and in
doing so he fails in his examinations. At last it becomes a choice
between his career and his children, between the present and the
future, and the children and the future win. Society loses just in the
degree that Lewisham himself loses, for he was fitted to be a
builder; and society has first, in the face of all his efforts, imperfectly
equipped him and then consistently refused to take advantage of his
talents.
Just as Lewisham is a potential builder of society who is defeated, so
Kipps is a specimen of the raw material, the muddled inferior
material with which society has to deal and refuses to deal. Kipps,
like Mr. Polly, is from the beginning a victim of accident, spawned on
the world, miseducated, apprenticed at fourteen to a Drapery
Bazaar. He grows up ignorant, confused, irresponsible; and then
suddenly, as accidentally as he was born, has £26,000 and
responsibility thrust upon him. The fortune of Kipps lifts him at once
out of the obscure negligible world of the populace and makes him a
figure to be reckoned with. Therein lies the comedy of the book. He
tries to make himself what in his own view a man of means ought to
be; naturally he sees money not as a force but as a thing to be
spent, and he finds that even from this point of view he has no
freedom of will, and that his lack of training inevitably places him in
the hands of equally irresponsible persons who want his money. He
wishes to build a house, designed after his own vaguely
apprehended needs and desires, and somehow under the wand of
the architect a house with eleven bedrooms springs from the
ground, a house plainly far beyond his own or Ann's power of
management, and the prospect of disrespectful servants, terrifying
callers, and a horde of scheming lawyers, tradesfolk and satellites.
And the life of Kipps under prosperity is summed up in the following
dialogue:
May one suggest how the significance of such a story as this varies
according to the point of view? In the ordinary literature of comedy,
Kipps would be merely a parvenu whose want of dignity and
ignorance of the right use of money are laughable—or, if the novelist
were a humanitarian, pitiful. To the socialist, on the other hand,
every incident of his life, every gesture of his mind, is a unique
indictment of things as they are. He stands for the whole waste of
human stuff in a world which has not learned how to economize
itself, whose every detail is accidental in a general chaotic absence
of social design.
In this aspect Tono-Bungay is the most powerful work of Wells. Just
as his romances of the future had exhibited the possible effects of
accidental heedless social conduct in the past, so his novels exhibit
the motives that produce this heedlessness to consequences. Thus
the world in which the Sleeper awakes, a world irrevocably ruled by
the bureaucratic trustees of an irresponsible private fortune, is just a
conceivable consequence of such a career as Uncle Ponderevo's, had
not catastrophe overwhelmed him and enabled Wells to point a
much more pregnant moral. Tono-Bungay is a great epic of
irresponsible capitalism from the socialist point of view. Uncle
Ponderevo is a born commercial meteor, and when he first enters
the book, a small druggist in a dead country town, he exhibits the
temperament of a Napoleon of finance spoiling for conquest. He
wants to Wake Up Wimblehurst, invent something, do something,
shove something.
CHAPTER III
The man who wrote that is not what is called a whole-hearted man
as regards any form of group-action. He does not "fit in." He is at
bottom a sceptic, and a sceptic is one who reduces every question to
the question of human nature. So that the socialism of Wells is
necessarily at variance with all the recognized group-forms of
socialism, Administrative, Philanthropic, and Revolutionary. I must
briefly indicate in each case what is the quality of this divergence.
As regards the first, he has a complete distrust of what Hilaire Belloc
has called the "Servile State;" and what he distrusts he virulently
dislikes. In his view, Administrative socialism, as it appears in Sidney
Webb and the Fabian Society, and in the tendency of contemporary
Liberalism, has led to an excessive conservatism toward the existing
machinery of government, it has depended altogether too much on
organization without popular support, and as a result has tended to
throw the whole force of the socialist movement into a bureaucratic
regime of small-minded experts. The activity of the Fabians
especially, he says, has set great numbers of socialists working in
the old governmental machinery without realizing that the machinery
should have been reconstructed first. The whole tendency of this
method, as it is exhibited in the works of the English Liberal Party of
to-day, is toward a socialization of the poor without a corresponding
socialization of the rich; toward a more and more marked chasm
between the regimented workers and the free employers.
And it throws the control of affairs into the hands of a mass of highly
specialized officials, technical minds, mutually-unenlightened
experts. In an age when the progress of society depends upon
breaking down professional barriers, when the genuine scientist, for
instance, is a man who passes beyond his own science and sees the
inter-relationships of all knowledge, the mind which has been trained
in one habitual routine is the most dangerous type of mind to place
in authority. On the one hand, society depends upon the coöperation
of all sorts of specialists, their free discussion, and comparison of
methods, results, and aims; on the other experts in office are apt to
grow narrow, impatient, and contemptuous, seeing nothing beyond
their immediate work,—and this particularly when they have been
trained for administration without any wide experience of the world.
Therefore upon experts as such, in distinction from constructive and
coöperating specialists, Wells, with all the force of his belief in the
ventilating of knowledge and the humanizing of affairs, wages an
unceasing war. The First Men in the Moon satirizes, after the fashion
of Swift, a world where the expert view of life, not only in
administration but in all work, prevails. Each inhabitant of the Moon
has a single rigidly defined function, to which everything else in his
nature is accommodated. Thus certain types of machine-menders
are compressed in jars, while others are dwarfed to fit them for fine
work, "a really more humane proceeding", as Mr. Cavor observes,
"than our method of leaving children to grow into human beings and
then making machines of them." And in The Great State he returns
to his attack on government by experts: "Whatever else may be
worked out in the subtler answers our later time prepares, nothing
can be clearer than that the necessary machinery of government
must be elaborately organized to prevent the development of a
managing caste in permanent conspiracy, tacit or expressed, against
the normal man." And he adds: "The Great State will, I feel
convinced, regard changes in occupation as a proper circumstance in
the life of every citizen; it will value a certain amateurishness in its
service, and prefer it to the trite omniscience of the stale official."
One of the many and increasing indications, one might suggest, of
the remarkable tendency in Wells to find good in the old humanistic
Tory, as distinguished from the modern bureaucratic Liberal, view of
life.
But lest I be tempted to carry this latter suggestion too far just at
this point, I pass on to his equally virulent dislike of Philanthropic
socialism and the busy Superior Person in affairs; especially the type
of political woman so dear to Mrs. Humphry Ward's heart. If the
expert bureaucratic point of view represents the action of socialist
thought on the Liberal Progressive mind, so also the philanthropic
superior point of view represents the action of socialist thought on
the Conservative mind. It is arrogant, aggressive, and
condescending. It implies the raising of one's inferiors, and what
weak mortal should assume that she (for this happens to be a
mainly feminine affliction) is the standard according to which other
mortals ought to be raised?
Two of these energetic ladies have been pictured with a bitter
vividness by Wells in Altiora Bailey and Aunt Plessington, the former
summing up the Fabian-expert view, the latter summing up the
Superior-philanthropic view. Altiora has "P.B.P."—pro bono publico—
engraved inside her wedding ring. All the misery of the world she
marshals invincibly in statistics. She sees everything as existing in
types and classes; she pushes her cause with a hard, scheming, and
wholly self-centred eagerness, managing political dinners,
indefatigably compiling blue-books, dreaming of a world nailed as
tightly and firmly under the rule of experts as a carpet is nailed with
brass tacks.
On the other hand Aunt Plessington is the incarnation of a
"Movement" somewhat vague in purpose but always aggressively
beneficial to the helpless ones of the earth. "Her voice was the true
governing-class voice, a strangulated contralto, abundant and
authoritative; it made everything she said clear and important, so
that if she said it was a fine morning it was like leaded print in the
Times." Her mission is principally to interfere with the habits and
tastes of the working-class, making it impossible for them to buy
tobacco and beer or "the less hygienic and more palatable forms of
bread (which do not sufficiently stimulate the coatings of the
stomach)." She is, in short, one of those odious managing people
who know nothing of and care nothing for human nature, who
concern themselves wholly with the effects without penetrating to
the causes of misery, who see mankind as irrevocably divided into a
governing and a governed class, and whose idea of government is to
make the governed as uncomfortably efficient as possible and as
lacking in free will. She is exactly one of those arrogant sterile souls,
in love with methods rather than men, who have made the Servile
State an imminent and horrid possibility and have turned so many
misinformed human beings (including Tolstoy) against socialism
altogether.
If Wells dislikes Administrative and Philanthropic socialism because
they are not sufficiently human, he has an equal aversion to what is
called orthodox, that is to say, Revolutionary socialism; and in this
he includes all socialism that is fundamentally economic. "I have
long since ceased to trouble about the economics of human society,"
says Stratton in The Passionate Friends, in words we are justified in
taking as the opinion of Wells himself. "Ours are not economic but
psychological difficulties."
That statement is full of meaning. It expresses, not a fact but a
personal conviction—the personal conviction with which the
psychological constructive socialism of Wells begins. But before I
pass on to this I must make one comment that persists in my mind.
Nothing is more remarkable than the unanimity with which during
the last few years the advanced world has put all its eggs in the
basket of pragmatism, the basket that has been so alluringly
garnished by Bergson's Creative Evolution, In this movement of
thought Wells has inevitably become one of the leaders, and his
practical desertion of the socialist cause is one of the main
symptoms of it. The creative energies of men, where society as a
whole is concerned, are, in this philosophy, conceived as bursting
through the husks and institutions of the world, not consciously
destroying them but shedding them incidentally and passing on.
Now as regards sociology there is an obvious fatalism in that; for the
burden of proof lies once more on a personal basis, on a personal
basis qualified by the capacity of the person. It is true that this
creative and constructive tendency, like the total tendency of
modern life, is in the direction of socialism, it is true that a thousand
elements in modern life which could never be engaged in the class-
war are led by it into line with socialism. Yet there capitalism is! Only
the black-browed Marxian steadily contemplates the fact that year by
year the rich compound their riches and the poor their poverty, while
those that have no chance of creative outlets plant dynamite.
I do not mean that Wells is "wrong" in abandoning the economic for
the psychological approach,—that is plainly the inevitable course for
him. I wish simply to mark a distinction. The gospel of Wells is an
entirely personal one; it frankly concerns itself with the inner
realities of the human mind, and in that lies its great importance.
But let us discriminate. Like every purely personal doctrine it
contains, in relation to the facts and causes of society, a certain
quietism. It withdraws the mind from corporate action and lays
emphasis on corporate thought. But it recognizes no corporate
enemy. To be an opponent of capitalism as such, is, in this
philosophy, as quaint and crude and crusty as to be an anti-suffragist
or a believer in politics (for it has become the fashion to believe with
fervor in the franchise and scarcely to believe at all in what the
franchise stands for).
There is then a certain danger in the creative pragmatism of this
particular time. If it actually does penetrate to the head men of the
world, if it is able to generate what I suppose may be called a "moral
equivalent" of duty—and there is almost a probability that it will—the
hazard is won. If it does not—and many keen thinkers and men of
action are obdurate—then we shall simply have the fait accompli
with compound interest. What if it should turn out in the end, after
the best brains of socialism had all withdrawn from the economic
programme of socialism, that capitalism grows all the greener in the
sunlight of their tacit consent? There is Congress, there is
Parliament, and there they propose to remain. Suppose they are not
converted from the top? Is it altogether wise to stop persecuting
them from the bottom?
So much before I pass on. This comment does not qualify the
teaching of Wells. It merely supplements it from the economic side,
and the supplement seems to me an important one.
Of a piece with his whole point of view is that he calls the right
sociological method not a scientific but an artistic method: it consists
of the making and comparing of Utopias. This idea he sets forth in
his paper The So-called Science of Sociology. "What is called the
scientific method," he says, "the method of observation, of theory
about these observations, experiments in verification of that theory
and confirmation or modification, really 'comes off' in the sciences in
which the individuality of the units can be pretty completely
ignored." The method that is all-important in the primary physical
sciences where the individuality of atoms and molecules may
conveniently be ignored for the sake of practical truth, becomes in
his view proportionately untrue as the sciences in their gradation
approach the human world. "We cannot," he says in First and Last
Things, "put humanity into a museum and dry it for examination;
our one still living specimen is all history, all anthropology, and the
fluctuating world of men. There is no satisfactory means of dividing
it and nothing in the real world with which to compare it. We have
only the remotest idea of its 'life-cycle' and a few relics of its origin
and dreams of its destiny." And in the paper I have just mentioned
he speaks of the Social Idea as a thing "struggling to exist and
realize itself in a world of egotisms, animals, and brute matter....
Now I submit it is not only a legitimate form of approach, but
altogether the most promising and hopeful form of approach, to
endeavor to disentangle and express one's personal version of that
idea, and to measure realities from the standpoint of that realization.
I think, in fact, that the creation of Utopias—and their exhaustive
criticism—is the proper and distinctive method of sociology." This
notion of sociology as properly artistic in method and diagnostic in
aim indicates his main divergence from the methods and aims of
Comte and Spencer.
And so one turns to his own illustration of this belief, A Modern
Utopia. It is a beautiful Utopia, beautifully seen and beautifully
thought; and it has in it some of that flavor of airy unrestraint one
finds in News from Nowhere. Morris, of course, carries us into a
world where right discipline has long since produced right will, so
wholly and instinctively socialized that men can afford to be as free
as anarchists would have the unsocialized men of our own time, a
world such as Goethe had in mind when he said: "There is in man a
force, a spring of goodness which counterbalances egoism; and if by
a miracle it could for a moment suddenly be active in all men, the
earth would at once be free from evil." Well, that is the miracle
which has in some way just taken place before the curtain goes up
on most Utopias; and I think that Wells has never been more skilful
than in keeping this miracle quietly in his bag of tricks and devising
meanwhile a plausible transition between us and that better world.
It all happens in a moment and we are there. By an amazing
legerdemain of logic he leaps the gap and presents us with a planet
which at every point tallies with our own. It is a planet which does
not contain a State but is a State, the flexible result of a free social
gesture.
Mankind in the Making should be taken as introductory to A Modern
Utopia. It is the sketch of a method towards attaining such a world
state. It is a kind of treatise on education based on the assumption
that "our success or failure with the unending stream of babies is the
measure of our civilization." It opens with a complete repudiation of
"scientific" breeding, as a scheme which ignores the uniqueness of
individual cases and the heterogeneous nature of human ideals. "We
are," says Wells, "not a bit clear what points to breed for, and what
points to breed out;" while the interplay of strong and varied
personalities we desire is contradictory to any uniform notions of
beauty, capacity, and sanity, which thus cannot be bred for, so to
speak, in the abstract. But in A Modern Utopia he outlines certain
conditions limiting parentage, holding it necessary that in order to be
a parent a man must be above a certain minimum of capacity and
income, failing which he is indebted to the State for the keep of his
children. Motherhood is endowed and becomes in this way a normal
and remunerative career, which renders the mother capable of giving
her time to the care and education of her children, as millions are
not in a wage-earning civilization, and makes both her and her
children independent of the ups and downs of her husband. His very
detailed suggestions about the education of young children
(illustrated also in The Food of the Gods) are at once a reminiscence
of Rabelais and an anticipation of Madame Montessori. He insists
upon uniform pronunciation (a very important matter in England,
where diversity of language is one of the bulwarks of a rigid class-
system), the universality and constant revision of text-books, the
systematic reorganization of public library and bookselling methods,
with a view to making the race think as a whole. He urges the
necessity of rescuing literature from the accidents of the book-
market by endowing critical reviews, chairs for the discussion of
contemporary thought, and qualified thinkers and writers regardless
of their special bias or principles. To strike a mean between the
British abuse of government by hereditary privilege and the
American abuse of government by electoral machines he ingeniously
proposes the election of officials by the jury method, twenty or thirty
men being set aside by lot to determine the proper holders of office.
And he is convinced of the importance in a democracy of abundant
honors, privileges, even titles, and abundant opportunities for fruitful
leisure.
I have already spoken of his belief that the right sociological method
is the creation and comparison of individual Utopias. Thus his own
free-hand sketch of a better world is, in fact, a criticism of all
previous works of the kind. As distinguished from them the modern
Utopia, he says, has to present not a finally perfect stage but a
hopefully ascending one; it has to present men not as uniform types
but as conflicting individualities with a common bond; and moreover
it has to occupy, not some remote island or province "over the
range" but a whole planet. The Utopia of Wells is a world which
differs from the present world in one fundamental respect only—it
has one initial advantage: that every individual in it has been started
right, in the degree in which the collective knowledge of the world
has rendered that possible.
But there is no need for me to say anything more about these
books. They are the free and suggestive motions of a mind
inexhaustibly fertile and given to many devices. Anyone who has
read Wells at all is aware of his ingenuity, his equal capacity for large
schemes and minute details, his truly Japanese belief in radical
changes, once they are seen to be necessary and possible. And
indeed the details of social arrangement follow naturally and
profusely enough, once you get the frame of mind that wishes them.
Wells in his Utopia presupposes the frame of mind. In short, he puts
education first; he believes that the essential problems of the
present are not economic but psychological.
And here where the constructive theory of Wells begins, let me
quote a passage from The New Machiavelli that gives the gist of it:
Our website is not just a platform for buying books, but a bridge
connecting readers to the timeless values of culture and wisdom. With
an elegant, user-friendly interface and an intelligent search system,
we are committed to providing a quick and convenient shopping
experience. Additionally, our special promotions and home delivery
services ensure that you save time and fully enjoy the joy of reading.
textbookfull.com