100% found this document useful (2 votes)
20 views

Python Without Fear 1st Edition Brian Overland download

The document is a promotional piece for the book 'Python Without Fear' by Brian Overland, aimed at beginners looking to learn Python programming. It provides links to download the book and other related titles, emphasizing the accessibility and user-friendly approach of the content. The book covers various Python concepts, from basic syntax to advanced features, making it suitable for learners with different styles.

Uploaded by

noniezzofiaxh
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
100% found this document useful (2 votes)
20 views

Python Without Fear 1st Edition Brian Overland download

The document is a promotional piece for the book 'Python Without Fear' by Brian Overland, aimed at beginners looking to learn Python programming. It provides links to download the book and other related titles, emphasizing the accessibility and user-friendly approach of the content. The book covers various Python concepts, from basic syntax to advanced features, making it suitable for learners with different styles.

Uploaded by

noniezzofiaxh
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/ 54

Python Without Fear 1st Edition Brian Overland

download

https://textbookfull.com/product/python-without-fear-1st-edition-
brian-overland/

Download more ebook from https://textbookfull.com


We believe these products will be a great fit for you. Click
the link to download now, or visit textbookfull.com
to discover even more!

Supercharged Python Take Your Code to the Next Level


Brian Overland

https://textbookfull.com/product/supercharged-python-take-your-
code-to-the-next-level-brian-overland/

Minds without fear : philosophy in the Indian


renaissance 1st Edition Nalini Bhushan

https://textbookfull.com/product/minds-without-fear-philosophy-
in-the-indian-renaissance-1st-edition-nalini-bhushan/

Corporate Liability for Insider Trading 1st Edition


Juliette Overland

https://textbookfull.com/product/corporate-liability-for-insider-
trading-1st-edition-juliette-overland/

How to Face Death without Fear Preparing to Meet Life s


Final Challenge Lama Zopa Rinpoche

https://textbookfull.com/product/how-to-face-death-without-fear-
preparing-to-meet-life-s-final-challenge-lama-zopa-rinpoche/
Survival Chinese: How to Communicate without Fuss or
Fear Instantly! (A Mandarin Chinese Language
Phrasebook) Boye Lafayette De Mente

https://textbookfull.com/product/survival-chinese-how-to-
communicate-without-fuss-or-fear-instantly-a-mandarin-chinese-
language-phrasebook-boye-lafayette-de-mente/

Public Brainpower: Civil Society and Natural Resource


Management 1st Edition Indra Overland (Eds.)

https://textbookfull.com/product/public-brainpower-civil-society-
and-natural-resource-management-1st-edition-indra-overland-eds/

Fear No Evil 1st Edition Ivy Fox

https://textbookfull.com/product/fear-no-evil-1st-edition-ivy-
fox/

Without Choice 1st Edition Elizabeth Andrews

https://textbookfull.com/product/without-choice-1st-edition-
elizabeth-andrews/

Only Fear Mindhunters 1 1st Edition Anne Marie Becker

https://textbookfull.com/product/only-fear-mindhunters-1-1st-
edition-anne-marie-becker/
Python Without Fear

Overland_Book.indb i 8/31/17 12:56 PM


This page intentionally left blank
Python Without Fear
A Beginner’s Guide That
Makes You Feel Smart

Brian Overland

Boston • Columbus • Indianapolis • New York • San Francisco • Amsterdam • Cape Town
Dubai • London • Madrid • Milan • Munich • Paris • Montreal • Toronto • Delhi • Mexico City
São Paulo • Sydney • Hong Kong • Seoul • Singapore • Taipei • Tokyo

Overland_Book.indb iii 8/31/17 12:56 PM


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 the publisher was
aware of a trademark claim, the designations have been printed with initial capital letters or
in all capitals.
The author and publisher have taken care in the preparation of this book, but make no
expressed or implied warranty of any kind and assume no responsibility for errors or omissions.
No liability is assumed for incidental or consequential damages in connection with or arising
out of the use of the information or programs contained herein.
For information about buying this title in bulk quantities, or for special sales opportunities
(which may include electronic versions; custom cover designs; and content particular to your
business, training goals, marketing focus, or branding interests), please contact our corporate
sales department at corpsales@pearsoned.com or (800) 382-3419.
For government sales inquiries, please contact governmentsales@pearsoned.com.
For questions about sales outside the U.S., please contact international@pearsoned.com.
Visit us on the Web: informit.com/aw
Library of Congress Catalog Number: 2017946292
Copyright © 2018 Pearson Education, Inc.
All rights reserved. Printed in the United States of America. This publication is protected by
copyright, and permission must be obtained from the publisher prior to any prohibited repro-
duction, storage in a retrieval system, or transmission in any form or by any means, electronic,
mechanical, photocopying, recording, or likewise. For information regarding permissions,
request forms and the appropriate contacts within the Pearson Education Global Rights &
Permissions Department, please visit www.pearsoned.com/permissions/.
ISBN-13: 978-0-13-468747-6
ISBN-10: 0-13-468747-7
1 17

Overland_Book.indb iv 8/31/17 12:56 PM


For all my beloved four-legged friends:
Skyler, Orlando, Madison, Cleo, and Pogo.

Overland_Book.indb v 8/31/17 12:56 PM


This page intentionally left blank
Contents
Preface xvii
Steering Around the “Gotchas” xvii
How to Think “Pythonically” xvii
Intermediate and Advanced Features xviii
Learning in Many Different Styles xviii
What’s Going on “Under the Hood” xviii
Why Python? xix

Acknowledgments xxi
Author Bio xxiii

Chapter 1 Meet the Python 1


A Brief History of Python 1
How Python Is Different 2
How This Book Works 3
Installing Python 4
Begin Using Python with IDLE 6
Correcting Mistakes from Within IDLE 6
Dealing with Ends of Lines 7
Additional Help: Online Sources 8

vii

Overland_Book.indb vii 8/31/17 12:56 PM


viii Contents

Chapter 2 A Python Safari: Numbers 9


Python and Numbers 9
Interlude Why Doesn’t C++ Support Infinite Integers? 11
Interlude How Big Is a Google? 13
Python and Floating-Point Numbers 14
Assigning Numbers to Variables 17
Interlude What Do Python Assignments Really Do? 21
Variable-Naming Conventions in This Book 23
Some Python Shortcuts 23
Chapter 2 Summary 26

Chapter 3 Your First Programs 29


Temperatures Rising? 29
Interlude Python’s Use of Indentation 33
Putting in a Print Message 35
Syntax Summaries 36
Example 3.1. Quadratic Equation as a Function 38
How It Works 39
Getting String Input 41
Getting Numeric Input 43
Example 3.2. Quadratic Formula with I/O 44
How It Works 45
Formatted Output String 46
Example 3.3. Distance Formula in a Script 47
How It Works 48
Chapter 3 Summary 50

Chapter 4 Decisions and Looping 53


Decisions Inside a Computer Program 53
Conditional and Boolean Operators 55
The if, elif, and else Keywords 56
Interlude Programs and Robots in Westworld 56
Example 4.1. Enter Your Age 59
How It Works 60

Overland_Book.indb viii 8/31/17 12:56 PM


Contents ix
while: Looping the Loop 60
Example 4.2. Factorials 63
How It Works 64
Optimizing the Code 65
Example 4.3. Printing Fibonacci Numbers 67
How It Works 69
“Give Me a break” Statement 70
Example 4.4. A Number-Guessing Game 71
How It Works 72
Interlude Binary Searches and “O” Complexity 74
Chapter 4 Summary 75

Chapter 5 Python Lists 77


The Python Way: The World Is Made of Collections 77
Processing Lists with for 80
Modifying Elements with for (You Can't!) 82
Example 5.1. A Sorting Application 83
How It Works 84
Optimizing the Code 84
Indexing and Slicing 85
Copying Data to Slices 88
Ranges 89
Example 5.2. Revised Factorial Program 91
How It Works 91
Optimizing the Code 92
Example 5.3. Sieve of Eratosthenes 93
How It Works 94
Optimizing the Code 96
List Functions and the in Keyword 97
Interlude Who Was Eratosthenes? 98
Chapter 5 Summary 99

Chapter 6 List Comprehension and Enumeration 101


Indexes and the enumerate Function 101
The Format String Method Revisited 103
Example 6.1. Printing a Table 104
How It Works 105

Overland_Book.indb ix 8/31/17 12:56 PM


x Contents

Simple List Comprehension 106


Example 6.2. Difference Between Squares 109
How It Works 110
Interlude Proving the Equation 111
“Two-Dimensional” List Comprehension 112
List Comprehension with Conditional 114
Example 6.3. Sieve of Eratosthenes 2 115
How It Works 116
Optimizing the Code: Sets 117
Example 6.4. Pythagorean Triples 118
How It Works 119
Interlude The Importance of Pythagoras 120
Chapter 6 Summary 123

Chapter 7 Python Strings 125


Creating a String with Quote Marks 125
Indexing and “Slicing” 127
String/Number Conversions 130
Example 7.1. Count Trailing Zeros 131
How It Works 132
Interlude Python Characters vs. Python Strings 135
Stripping for Fun and Profit 135
Example 7.2. Count Zeros, Version 2 137
How It Works 137
Let’s Split: The split Method 138
Building Strings with Concatenation (+) 139
Example 7.3. Sort Words on a Line 141
How It Works 142
The join Method 143
Chapter 7 Summary 144

Chapter 8 Single-Character Ops 147


Naming Conventions in This Chapter 147
Accessing Individual Characters (A Review) 148
Getting Help with String Methods 148
Testing Uppercase vs. Lowercase 149
Converting Case of Letters 150

Overland_Book.indb x 8/31/17 12:56 PM


Contents xi
Testing for Palindromes 151
Example 8.1. Convert Strings to All Caps 152
How It Works 153
Optimizing the Code 154
Example 8.2. Completing the Palindrome Test 154
How It Works 156
Optimizing the Code 157
Interlude Famous Palindromes 158
Converting to ASCII Code 159
Converting ASCII to Character 160
Example 8.3. Encode Strings 161
How It Works 162
Interlude The Art of Cryptography 164
Example 8.4. Decode Strings 164
How It Works 165
Chapter 8 Summary 166

Chapter 9 Advanced Function Techniques 167


Multiple Arguments 167
Returning More Than One Value 168
Interlude Passing and Modifying Lists 170
Example 9.1. Difference and Sum of Two Points 172
How It Works 172
Arguments by Name 173
Default Arguments 174
Example 9.2. Adding Machine 176
How It Works 176
Optimizing the Code 177
Importing Functions from Modules 178
Example 9.3. Dice Game (Craps) 179
How It Works 180
Interlude Casino Odds Making 182
Chapter 9 Summary 185

Chapter 10 Local and Global Variables 187


Local Variables, What Are They Good For? 187
Locals vs. Globals 188
Introducing the global Keyword 190

Overland_Book.indb xi 8/31/17 12:56 PM


xii Contents

The Python “Local Variable Trap” 190


Interlude Does C++ Have Easier Scope Rules? 191
Example 10.1. Beatles Personality Profile (BPP) 192
How It Works 195
Example 10.2. Roman Numerals 196
How It Works 197
Optimizing the Code 198
Interlude What’s Up with Roman Numerals? 200
Example 10.3. Decode Roman Numerals 201
How It Works 202
Optimizing the Code 203
Chapter 10 Summary 204

Chapter 11 File Ops 207


Text Files vs. Binary Files 207
The Op System (os) Module 208
Interlude Running on Other Systems 211
Open a File 211
Let’s Write a Text File 213
Example 11.1. Write File with Prompt 214
How It Works 214
Read a Text File 216
Files and Exception Handling 217
Interlude Advantages of try/except 219
Example 11.2. Text Read with Line Numbers 220
How It Works 221
Other File Modes 223
Chapter 11 Summary 224

Chapter 12 Dictionaries and Sets 227


Why Do We Need Dictionaries, Ms. Librarian? 227
Adding and Changing Key-Value Pairs 229
Accessing Values 230
Searching for Keys 231
Interlude What Explains Dictionary “Magic”? 232
Example 12.1. Personal Phone Book 232
How It Works 234

Overland_Book.indb xii 8/31/17 12:56 PM


Contents xiii
Converting Dictionaries to Lists 235
Example 12.2. Reading Items by Prefix 236
How It Works 238
Example 12.3. Loading and Saving to a File 238
How It Works 240
All About Sets 241
Operations on Sets 242
Interlude What’s So Important About Sets? 244
Example 12.4. Revised Sieve of Eratosthenes 244
How It Works 245
Chapter 12 Summary 246

Chapter 13 Matrixes: 2-D Lists 249


Simple Matrixes 249
Accessing Elements 250
Irregular Matrixes and Length of a Row 251
Multiplication (*) and Lists 252
The Python Matrix Problem 253
How to Create N*M Matrixes: The Solution 254
Interlude Why Isn’t It Easier? 255
Example 13.1. Multiplication Table 256
How It Works 257
Example 13.2. User-Initialized Matrix 258
How It Works 259
Optimizing the Code 260
How to Rotate a Matrix 261
Interlude Pros and Cons of Garbage Collection 263
Example 13.3. Complete Rotation Example 264
How It Works 266
Optimizing the Code 267
Chapter 13 Summary 268

Chapter 14 Winning at Tic-Tac-Toe 271


Design of a Tic-Tac-Toe Board 271
Plan of This Chapter 273
Phase 1 273
Phase 2 273
Phase 3 273

Overland_Book.indb xiii 8/31/17 12:56 PM


xiv Contents

Python One-Line if/else 274


Example 14.1. Simple Two-Player Game 274
How It Works 276
Interlude Variations on Tic-Tac-Toe 279
The count Method for Lists 279
Example 14.2. Two-Player Game with Win Detection 279
How It Works 282
Introducing the Computer Player 285
Example 14.3. Computer Play: The Computer Goes First 287
How It Works 290
Playing Second 291
Interlude The Art of Heuristics 292
Chapter 14 Summary 294

Chapter 15 Classes and Objects I 295


What’s an Object? 295
Classes in Python 296
How Do I Define a Simple Class? 297
How Do I Use a Class to Create Objects? 297
How Do I Attach Data to Objects? 298
How Do I Write Methods? 300
The All-Important _ _init_ _ Method 301
Interlude Why This self Obsession? 302
Design for a Database Class 303
Interlude C++ Classes Compared to Python 304
Example 15.1. Tracking Employees 305
How It Works 307
Defining Other Methods 309
Design for a Point3D Class 310
Point3D Class and Default Arguments 312
Three-Dimensional Tic-Tac-Toe 312
Example 15.2. Looking for a 3-D Win 313
How It Works 314
Example 15.3. Calculating Ways of Winning 315
How It Works 317
Optimizing the Code 317
Chapter 15 Summary 318

Overland_Book.indb xiv 8/31/17 12:56 PM


Contents xv

Chapter 16 Classes and Objects II 321


Getting Help from Doc Strings 321
Function Typing and “Overloading” 323
Interlude What Is Duck Typing? 325
Variable-Length Argument Lists 326
Example 16.1. PointN Class 327
How It Works 329
Optimizing the Code 330
Inheritance 331
The Fraction Class 333
Example 16.2. Extending the Fraction Class 334
How It Works 335
Class Variables and Methods 337
Instance Variables as “Default” Values 339
Example 16.3. Polygon “Automated” Class 340
How It Works 342
Interlude OOPS, What Is It Good For? 343
Chapter 16 Summary 344

Chapter 17 Conway’s Game of Life 347


Interlude The Impact of “Life” 347
Game of Life: The Rules of the Game 348
Generating the Neighbor Count 350
Design of the Program 352
Example 17.1. The Customized Matrix Class 352
How It Works 353
Moving the Matrix Class to a Module 354
Example 17.2. Printing a Life Matrix 355
How It Works 355
The Famous Slider Pattern 358
Example 17.3. The Whole Game of Life Program 358
How It Works 360
Interlude Does “Life” Create Life? 363
Chapter 17 Summary 364

Overland_Book.indb xv 8/31/17 12:56 PM


xvi Contents

Chapter 18 Advanced Pythonic Techniques 367


Generators 367
Exploiting the Power of Generators 369
Example 18.1. A Custom Random-Number Generator 370
How It Works 372
Interlude How Random Is “Random”? 373
Properties 375
Getter Methods 376
Setter Methods 377
Putting Getters and Setters Together 378
Example 18.2. Multilevel Temperature Object 379
How It Works 380
Decorators: Functions Enclosing Other Functions 382
Python Decoration 385
Example 18.3. Decorators as Debugging Tools 387
How It Works 388
Chapter 18 Summary 389

Appendix A Python Operator Precedence Table 391

Appendix B Summary of Most Important Formatting Rules


for Python 3.0 393
1. Formatting Ordinary Text 393
2. Formatting Arguments 393
3. Specifying Order of Arguments 393
4. Right Justification Within Field of Size N 394
5. Left Justification Within Field of Size N 394
6. Truncation: Limit Size of Print Field 394
7. Combined Truncation and Justification 395
8. Length and Precision of Floating-Point Numbers 395
9. The Padding Character 395

Appendix C Glossary 397

Index 407

Overland_Book.indb xvi 8/31/17 12:56 PM


Preface
There’s a lot of free programming instruction out there, and much of it’s about
Python. So for a book to be worth your while, it’s got to be good…it’s got to
be really, really, really good.
I wrote this book because it’s the book I wish was around when I was first
learning Python a few years back. Like everybody else, I conquered one concept
at a time by looking at almost a dozen different books and consulting dozens
of web sites.
But this is Python, and it’s not supposed to be difficult!
The problem is that not all learning is as easy or fast as it should be. And
not all books or learning sites are fun. You can, for example, go from site to
site just trying to find the explanation that really works.
Here’s what this book does that I wish I’d had when I started learning.

Steering Around the “Gotchas”


Many things are relatively easy to do in Python, but a few things that ought
to be easy are harder than they’d be in other languages. This is especially
true if you have any prior background in programming. The “Python way”
of doing things is often so different from the approach you’d use in any other
language, you can stare at the screen for hours until someone points out the
easy solution.
Or you can buy this book.

How to Think “Pythonically”


Closely related to the issue of “gotchas” is the understanding of how to think
in Python. Until you understand Python’s unique way of modeling the world,

xvii

Overland_Book.indb xvii 8/31/17 12:56 PM


xviii Preface

you might end up writing a program the way a C programmer would. It runs,
but it doesn’t use any of the features that make Python such a fast develop-
ment tool.
a_list = ['Don\'t', 'do', 'this', 'the' ,'C', 'way']
for x in a_list:
print(x, end=' ')
This little snippet prints
Don't do this the C way

Intermediate and Advanced Features


Again, although Python is generally easier than other languages, that’s not
universally true. Some of the important intermediate features of Python are
difficult to understand unless well explained. This book pays a lot of atten-
tion to intermediate and even advanced features, including list comprehension,
generators, multidimensional lists (matrixes), and decorators.

Learning in Many Different Styles


In this book, I present a more varied teaching style than you’ll likely find else-
where. I make heavy use of examples, of course, but sometimes it’s the right
conceptual figure or analogy that makes all the difference. Or sometimes it’s
working on exercises that challenge you to do variations on what’s just been
taught. But all of the book’s teaching styles reinforce the same ideas.

What’s Going on “Under the Hood”


Although this book is for people who may be new to programming altogether,
it also caters to people who want to know how Python works and how it’s fun-
damentally different “under the hood.” That is, how does Python carry out
the operations internally? If you want more than just a simplistic introduction,
this book is for you.

Overland_Book.indb xviii 8/31/17 12:56 PM


Preface xix

Why Python?
Of course, if you’re trying to decide between programming languages, you’ll
want to know why you should be using Python in the first place.
Python is quickly taking over much of the programming world. There are
some things that still require the low-level capabilities of C or C++, but you’ll
find that Python is a rapid application development tool; it multiplies the
effort of the programmer. Often, in a few lines of code, you’ll be able to do
amazing things.
More specifically, a program that might take 100 lines in Python could
potentially take 1,000 or 2,000 lines to write in C. You can use Python as
“proof of concept”: write a Python program in an afternoon to see whether
it fulfills the needs of your project; then after you’re convinced the program is
useful, you can rewrite it in C or C++, if desired, to make more efficient use of
computer resources.
With that in mind, I’ll hope you’ll join me on this fun, exciting, entertaining
journey. And remember this:
x = ['Python', 'is', 'cool']
print(' '.join(x))

Register your copy of Python Without Fear on the InformIT site for con-
venient access to updates and/or corrections as they become available. To
start the registration process, go toinformit.com/register and log in or create
an account. Enter the product ISBN (9780134687476) and click Submit. Look
on the Registered Products tab for an Access Bonus Content link next to
this product, and follow that link to access any available bonus materials.
If you would like to be notified of exclusive offers on new editions and
updates, please check the box to receive email from us.

Overland_Book.indb xix 8/31/17 12:56 PM


This page intentionally left blank
Acknowledgments
It’s customary for authors to write an acknowledgments page, but in this case,
there’s a particularly good reason for one. There is no chapter in this book
that wasn’t strongly influenced by one of the collaborators: retired Microsoft
programmer (and software development engineer) John Bennett.
John, who has used Python for a number of years—frequently to help
implement his own high-level script languages—was particularly helpful in
pointing out that this book should showcase “the Python way of doing things.”
So the book covers not just how to transcribe a Python version of a C++
solution but rather how to take full advantage of Python concepts—that is, how
to “think in Python.”
I should also note that this book exists largely because of the moral support
of two fine acquisition editors: Kim Boedigheimer, who championed the
project early on, and Greg Doench, whom she handed the project off to.
Developmental and technical editors Michael Thurston and John Wargo made
important suggestions that improved the product. My thanks go to them, as well
as the editorial team that so smoothly and cheerfully saw the manuscript
through its final phases: Julie Nahil, Kim Wimpsett, Angela Urquhart, and
Andrea Archer.

xxi

Overland_Book.indb xxi 8/31/17 12:56 PM


This page intentionally left blank

Overland_Book.indb xxii 8/31/17 12:56 PM


Author Bio
At one time or another, Brian Overland was in charge of, or at least influential in,
documenting all the languages that Microsoft Corporation ever sold: Macro
Assembler, FORTRAN, COBOL, Pascal, Visual Basic, C, and C++. Unlike
some people, he wrote a lot of code in all these languages. He’d never document
a language he couldn’t write decent programs in.
For years, he was Microsoft’s “go to” man for writing up the use of utilities
needed to support new technologies, such as RISC processing, linker extensions,
and exception handling.
The Python language first grabbed his attention a few years ago, when he
realized that he could write many of his favorite applications—the Game of
Life, for example, or a Reverse Polish Notation interpreter—in a smaller space
than any computer language he’d ever seen.
When he’s not exploring new computer languages, he does a lot of other
things, many of them involving writing. He’s an enthusiastic reviewer of films
and writer of fiction. He’s twice been a finalist in the Pacific Northwest Literary
Contest.

xxiii

Overland_Book.indb xxiii 8/31/17 12:56 PM


This page intentionally left blank

Overland_Book.indb xxiv 8/31/17 12:56 PM


1
Meet the Python
What if I told you there’s a computer language that’s easier to learn, easier to
get started with, and easier to accomplish a great deal with, using only a few
lines of code, than other computer languages?
In the opinion of millions, Python is that language. Derived from a lan-
guage called ABC (as in “simple as ABC”), it’s gained a massive worldwide
following over the last two decades. So many programmers have joined the
Python community that there are more than 100,000 free packages that work
with the basic Python setup.
Come join the Python stampede. In this book I show you how to get started
even if you have limited programming experience. I also steer you around the
“gotchas”—the things Python does so differently that they trip up experienced
programmers. This book is for new programmers as well as experienced pro-
grammers alike, and it discusses what goes on under the covers.

A Brief History of Python


Python was invented in 1991 by
Dutch programmer Guido van It’s as easy as
Rossum, who derived much of it “ABC”!!
from the ABC language (not to
be confused with C).
ABC had many features that A B C
exist today in Python. Van Ros-
sum, whose title in the Python
world is Benevolent Dictator
for Life (BDFL), also incorpo-
rated elements of the Modula-3
language.

Overland_Book.indb 1 8/31/17 12:56 PM


2 Chapter 1 Meet the Python

Van Rossum named the language after the BBC comedy series Monty
Python’s Flying Circus, so the connection to pythons is indirect, although
troupe member John Cleese originally came up with “Python” as suggesting
something “slithering and slimy” (source: Wikipedia.org). So there you have
it—there is a connection to reptiles after all.
Since then, several versions of Python have been developed, adding important
capabilities, the latest of which is Python 3.0. This book uses Python 3.0,
although it includes notes about adapting examples to Python 2.0.

How Python Is Different


The first thing to know about Python is that Python is free.
Many Python extensions are free and come with the basic download. These
modules offer features such as math, date/time, fractions, randomization, and
tkinter, which supports a graphical user interface that runs across multiple
platforms. Again, all are free.
Python’s built-in numeric support is impressive, as it includes complex
numbers, floating-point, fractions (from the Fractions module), and “infinite
integers.”
Python has attracted an extraordinary following. Many developers provide
libraries—called packages—to their fellow Python programmers, mostly free
of charge. You can get gain access by searching for Python Package Index in
your Internet browser and then going to the site. As of this writing, the site
offers access to more than 107,000 packages.
At first glance, a Python program may look something like code in other
languages, but a close look reveals major differences.

 Unlike most languages, Python has no “begin block” or “end block” syntax—
all relationships are based on indentation! Although this might seem risky to a
C programmer, it enforces a consistent look that’s more comprehensible to
beginners.
 Python has no variable declarations. You create variables by assigning values
to them. This goes a long way toward simplifying the language syntactically,
but it also creates hidden “gotchas” at a deep level. This book will steer you
around them.
 Python is built heavily on the idea of iteration, which means looping through
sequences. This concept is built deeply into high-level structures (lists, dictio-
naries, and sets). Use them well, and you’ll be able to get a great deal done in
a small space.

Overland_Book.indb 2 8/31/17 12:56 PM


How This Book Works 3
Python is often considered a “prototyping” or “rapid application development”
language because of these abilities. You can write a program quickly in Python.

1
If you later want to improve machine-level efficiency, you can later rewrite the
program in C or C++.

How This Book Works


I believe strongly in learning by example as well as by theory. The plan of
this book is to teach the basics of Python (as well as some intermediate and
advanced features) by doing the following:

 Introducing a Python feature, using syntax diagrams and short examples


 Showing a major example that demonstrates the practical application of the
feature
 Including a “How It Works” section that deconstructs the example code line
by line
 Listing a set of exercises that challenge you to do variations on the example

Because Python has an interactive development environment, IDLE, I often


invite you to follow along with the shorter examples, as well.
This book uses a number of icons in the margin to help give you additional
visual cues.
ord
These sections describe some basic rule of Python syntax. Anything meant
Keyw

to be entered at the keyboard precisely as shown (such as a keyword or punc-


tuation) is in bold. Meanwhile, placeholders, which contain text you supply
ntax yourself, are in italics. For example, in the syntax for the global statement, the
Key Sy

keyword itself is in bold, while the name of the variable—which you supply—
is in italics.
global variable_name
code This icon indicates a block of pseudocode, which systematically describes each
Pseudo

step of a program purely in English, not Python-ese. However, because Python


statements are often not so far from English, I don’t always need to use pseudocode.
It can still be helpful, on occasion, for summarizing program design.
Works
This icon indicates a section that deconstructs every line of a major example,
How It

or at least every line that isn’t already trivial.

Overland_Book.indb 3 8/31/17 12:56 PM


4 Chapter 1 Meet the Python

ses This icon indicates a section that provides exercises based on the preced-
Exerci

ing example. You’ll learn Python much faster if you try at least some of the
exercises.

izing
This icon precedes a section that shows how to revise or greatly improve an
Optim

example. These are not included for every example. Where this book does use
them, it’s because the example used the more obvious way to do something;
the “optimized” approach will then show how the more experienced, sophisti-
cated Python programmer would handle the job.

Installing Python
The steps for installing Python are essentially the same regardless of whether
you have a Windows-based system, Macintosh, or any other system that Python
supports. Here are the basic steps:

1 Go to the Python home page: python.org.


2 Open the Downloads menu.
3 If a Downloads for Windows screen appears, click the Python 3.6.1 button. If
your system does not run Windows, you’ll need to select another operating sys-
tem by examining all the choices in the Downloads menu.
4 Click the Save File button.
5 Find the file you just saved; any system will generally have a place that it puts
downloads. This saved file contains the Python installer. Double-click the name
of this saved file and follow the instructions.

If all goes well, Python is installed on your computer with all the basic mod-
ules, tkinter (GUI development) included. Now you have a choice to make.
To start using Python, you can use “basic interactive mode”—which is func-
tional but nothing special—or you can use IDLE, the interactive development
environment.
I strongly recommend the latter. IDLE does everything the basic interactive
mode does, and a great deal more. In the next section, I describe some ways of
using IDLE that can save you a lot of time later.
Here’s what basic interactive mode looks like. It offers only rudimentary
editing and no support for loading programs from text files.

Overland_Book.indb 4 8/31/17 12:56 PM


Other documents randomly have
different content
depth some words of passionate intolerance; if Peter should misapply
a psalm, and Paul indite mistaken prophecies; above all, if Jesus
should appear to believe in demonology, and not to have foreseen the
futurities of his Church,—these detected specks are felt like a total
eclipse; affrighted faith hides its face from them and shrieks; and he
who points them out, though only to show how pure the orb that
spreads behind, is denounced as a prophet of evil. The peaceful and
holy centre of religion is shaken by storms of angry erudition. Devout
ingenuity or indevout acuteness spend themselves in vitiating the
impartial course of historical criticism; neither of them reflecting, that,
if the topics in dispute are open to reasonable doubt, they cannot be
matter of revelation, and may be calmly looked at as objects of
natural thought. It is a thing alike dangerous and unbecoming that
religion should be narrowed to a miserable literary partisanship, bound
up with a disputed set of critical conclusions, unable to deliver its title-
deeds from a court of perpetual chancery, whose decisions are never
final. The time seems to have arrived for freeing the Protestant
Christianity from its superstitious adhesion to the mere letter of the
Gospel, and trusting more generously to that permanent inspiration,
those ever-living sources of truth within the soul, of which Gospel and
Epistle, the speeches of Apostles and the insight of Christ, are the pre-
eminent, rather than the lonely, examples. The primitive Gospel is not
in its form, but only in its spirit, the everlasting Gospel. It is
concerned, and, if we look to quantity alone, chiefly concerned, with
questions that have ceased to exist, and interests that no longer
agitate. It often reasons from principles we do not own, and is tinged
with feelings which we cannot share. Often do the most docile and
open hearts resort to it with reverent hopes which it does not realize,
and close it with a sigh of self-reproach or disappointment. With the
deep secrets of the conscience, the sublime hopes, the tender fears,
the infinite wonderings of the religious life, it deals less altogether
than had been desired; and in touching them does not always glorify
and satisfy the heart. We are apt to long for some nearer reflection,
some more immediate help, of our existence in this present hour and
this English land, where our enemies are not Pharisees and
Sadducees, or our controversies about Beelzebub and his demons; but
where we would fain know how to train our children, to subdue our
sins, to ennoble our lot, to think truly of our dead. The merchant, the
scholar, the statesman, the heads of a family, the owner of an estate,
occupy a moral sphere, the problems and anxieties of which, it must
be owned, Evangelists and Apostles do not approach. Scarcely can it
be said that general rules are given, which include these particular
cases. For the Christian Scriptures are singularly sparing of general
rules. They are eminently personal, national, local. They tell us of
Martha and Mary, of Nicodemus and Nathaniel, but give few maxims
of human nature, or large formulas of human life: so that their
spiritual guidance first becomes available when its essence has been
translated from the special to the universal, and again brought down
from the universal to the modern application. They are felt to be an
inadequate measure of our living Christianity, and to leave untouched
many earnest thoughts that aspire and pray within the mind. One
divine gift, indeed, they impart to us,—the gracious and holy image of
Christ himself. Yet, somehow, even that sacred form appears with
more disencumbered beauty, and in clearer light, when regarded at a
little distance in the pure spaces of our thought, than when seen close
at hand on the historic canvas. It is not that the ideal figure is a
subjective fiction of our own, more perfect than the real. Every
lineament, every gesture, all the simple majesty, all the deep
expressiveness, we conceive to be justified and demanded by the
actual portraiture: our least hesitating veneration sees nothing that is
not there. But the original artists' sympathy we feel to have been
somewhat different from ours. They have labored to exhibit aspects
that move us little; and only faintly marked the traces that to us are
most divine. The view is often broken, the official dress turned into a
disguise. The local groups are in the way; the possessed and the
perverse obtrude themselves in front with too much noise; and the
refracting cloud of prophecy and tradition is continually thrown
between. So that the image has a distincter glory to the meditating
mind than to the reading eye.
All this, oftener perhaps felt than confessed, is perfectly natural and
innocent. It betrays the instinctive analysis by which our own
affections separate the divine from the human. Paul was right in his
principle, that in history the divine element lies hid; is missed at the
time, even by those who are its vehicle; and does not parade itself in
what they consciously design, but lurks in what they unconsciously
execute. It comes forth at "the end of the ages,"—the retrospect of
fifty generations instead of the foresight of one. This doctrine is true
of individuals, in proportion as they are great and good. They labor at
what is most difficult to them, and make it their end; but their
appointed power lies in what is easiest. They chiefly prize the beliefs
and the virtues most painfully won; but their highest truth dwells in
the trusts they cannot help, and their purest influence in the graces
they never willed, or knew to be their own. And it is true in history;
Paul himself signally illustrating the rule which he had applied to
earlier times. He had found, as he supposed, the Providence of the
Past, which all had missed, from Moses to Christ; but in his turn he
missed, as we perceive, the Providence of the Future, from himself to
us. The kind of agency which he anticipated for Christ bears no
resemblance to that which his religion has actually exercised. The only
fault we can find with Mr. Thom's admirable exposition is, that he
attributes to the Apostle too distinct an apprehension of Christ as an
impersonation of moral perfection; and supposes the purpose of the
Pauline Christianity to have been the establishment, as sole condition
of discipleship, of reverential sympathy with the type of character
realized in the Galilean life of Jesus. He says:—
"In contrast with such teachers" (the Ritual and the Dogmatic), "St.
Paul, in our present chapter (1 Corinthians ii.), refers both to the
matter and the manner of his own ministration of the Gospel. He did
not teach it as a Rhetorician, to attract admiration to himself, and give
more lively impressions of Paul the Orator than of Christ the
Redeemer from sin, nor as a Philosopher, to raise doubtful questions
on metaphysical subjects, and become the leader of a speculative
school; but as the Apostle of Jesus Christ, he proclaimed to the hearts
of men the practical and life-giving Gospel, that 'God was in Christ
reconciling the world unto himself'; that by the universal Saviour all
distinctions were for ever destroyed, and the whole family of God to
grow into the common likeness of that well-beloved Son,—for that
now neither circumcision availeth anything, nor uncircumcision, but
the renewal of the affections after the image of the Lord. Where could
an entrance be found for party divisions in a doctrine that professed
nothing, that aimed at nothing, except to awaken the consciousness
of sin within the heart, and, through trust in the God of holiness and
love revealed in Jesus, to lead it to repentance and life? All who felt
this love of Christ constraining them, cleansing their souls by the
divine image that had taken possession of their affections, and,
through the mercy it proclaimed, encouraging their penitence to look
for pardon from their God, must, of necessity, be one communion; for
this Gospel sentiment and hope could create no divisions amongst
those who had it,—and those who had it not were outside the
Christian pale, and, so far, could make no schisms within it. Now,
whence comes this Gospel sentiment, this new principle of life? Were
there any who had the exclusive power of communicating it? Did it
require to be introduced by any intricate reasonings, by any subtle
dialectics, which only the Masters in philosophy had at their
command? Not so, says St. Paul;—it is a spiritual feeling, excited by
moral sympathy, as soon as Christ is offered to the hearts that are
susceptible of the sentiment;—and in whatever bosom there is not
enough of the Spirit of God to cause that moral attraction to take
place, neither philosophy nor outward forms, nor aught else but the
divine image of goodness kept before the heart, can awaken the
slumbering sensibilities which are the very faculties of spiritual
apprehension, and which, as soon as they are alive, behold in Christ
the solution of their own struggling and imperfect existence, their
ideal and their rest. In regard to a sentiment so spiritual, a sympathy
with the image of God, where is the possibility of introducing party
divisions, and violating Christian unity? There can be but two parties,
—those that have the sentiment, and those that have it not. All
Christians constitute the one,—and as for the other, in relation to
Christian unity, they are not in question. Such is the argument of St.
Paul in this second chapter."—p. 30.
It may be quite true that the essential power of Christianity resides in
the image, ever present to the heart of Christendom, of a God
resembling Christ, and loving those who aspire to approach him
through the same resemblance. But we cannot find any traces of such
a conception in the writings of Paul. The "faith" on which he
exclusively insisted would be very incorrectly defined, we conceive, as
a reverence of Christ's character as morally like God. If we may judge
from the negative evidence of his letters, he appears to have had no
insight into the interior of his Master's earthly life, and no great
concern about it. There is an entire absence of any moral picture of
Jesus, who is presented in the Apostolic writings as an object, not of
retrospective veneration, but of expectant reliance; not of admiring
trust for personal qualities realized in a past career, but of hope
grounded on his official destiny in the future. One beauty of his
character is, indeed, appealed to in the Pauline writings, viz. his
humility and self-renunciation;[54] but even this is recognized, not on
historical, but on theocratic grounds; it is illustrated, not by anything
in his life, but by the fact of his death, conceived as a voluntary
postponement of his theocratic prerogatives, and an abrogation of his
exclusive nationality. He was a "spiritual" object to the Apostle of the
Gentiles, not from perception of the inner marks and graces of his
spirit, but from his being invisible and immortal, reserved in heaven
under external escape from the conditions of earthly life. Mr. Thom's
doctrine is a happy development of modern truth from ancient error;
but regarded as a mere interpretation, it perhaps sets down to the
Apostle's account a just moral appreciation of the past, instead of an
erroneous conception of the Providence of the future. The religion of
Christ has assuredly turned out a very different phenomenon from
anything that was anticipated at its origin. It was announced as a
Kingdom; as the king did not come, it became a Republic. It was
conceived as a State; it grew up into a Faith. It was proclaimed as the
world's end; it proved to be a fresh beginning. It was to consummate
the Law and the Prophets; and it confounded both. It was to cover
Pagan nations with shame and destruction; it embalmed their
literature, and was transformed by their philosophy. It was to deliver
over the earth to the pure and severe Monotheism of the Hebrews;
which, however, it so relaxed as to provoke Islam into existence to
proclaim again the monarchy of God. Its subjects were to be gathered
from the Jews and half-castes of the Eastern Synagogue; and its most
signal glories have been among the Teutonic nations, and the then
unsuspected continents of the West. In every element of its internal
power, in every direction of its external action, it has burst all the
proportions, left behind all the expectations, with which it was born;
and how can we continue to try it by the standard of its origin? Are
we to say, that, having promised one thing and become another, it is
not of God? That might be well, if it had fallen short of its own
professions,—disappointed us of dreams it had awakened of glory and
delight. But if it has been far better than its word; if, instead of
winding up the world's affairs, it has given them a new career; if for
Messiah's tame millennium we have the grand and struggling life of
Christendom, and for his closed books of judgment the yet open page
of human history; if for the earthly throne and sceptre of Christ,
sweeping away the treasures of past civilization, we have his heavenly
image and spirit, presiding over the re-birth of art, the awakening of
thought, the direction of law, and the organism of nations; if from the
dignity of outward sovereignty he has been raised to that of Lord of
the living conscience, not superseding the soul, but exercising it with
sorrow and aspiration; then, surely, in so outstripping itself, the
religion should win a more exceeding measure of trust and affection.
Had it only realized its first assurances, we should have thought it
divine; since it has so much surpassed them, we must esteem it
diviner. There is no reason for the common assumption that a religion
must be purest in its infancy. It is no less surrounded then, than at
each subsequent time, with human conditions, and transmitted
through human faculties; and when delivered to the world, embodied
in action or in speech, necessarily presents itself as a mixed product of
divine insight and of human thought,—of the living present and the
decaying past; a flash of heavenly fire on the outspread fuel upon the
altar of tradition. So it is with the Scriptures of the New Testament;
which are not the heavenly source, but the first earthly result and
expression of Christianity, and which present the perishable conditions
as well as the indestructible life of the religion. Only by the course of
time and Providence can these be disengaged from one another, and
the accidents of place and nation fall away. If there dwell in the midst
a divine productive element, the further it passes from the moment of
its nativity, the clearer and more august will it appear. It is like the
seed dropped at first on an unprepared and unexpectant ground;
which in its earliest development yields but a struggling and scanty
growth, but each season, as another generation of leaves falls from
the boughs, becomes the source, through richer nutriment, of fuller
forms; till at length, when it has spread the foliage of ages, making its
own soil, and deepening the luxuriance of its own roots, a forest in all
its glory covers the land, and waves in magnificence over continents
once bare of life and beauty. So is it with the germ of divine truth cast
upon the inhospitable conditions of history; it is small and feeble in its
earlier day; but when it has provided the aliment of its own growth,
and shed its reproductive treasures on the congenial mind of
generations and races, it starts into the proportions of a Christendom,
and becomes the shade and shelter of a world.
Much, therefore, as we value all attempts to illustrate the first records
of Christianity, and to detach what was purely human and transient in
its original form, we think that the religion itself cannot acknowledge
the competency of such investigations to decide upon its claims. From
a verdict on its first works, it has a right to appeal for judgment upon
the whole. It is the religion, not of John and Paul alone, but of
Christendom; without a comparative estimate of whose moral and
social genius, it can by no means be appreciated. The weakness and
inadequacy of all narrower methods of defence will in the end drive
the clergy to occupy this larger basis of operations. And the change
will be not more favorable to the logic of their cause than to the
charity of their disposition. So long as the Scriptures alone are taken
as the standard, no more than one creed, at most, can be regarded as
concurrent with the Christian faith. But when the entire existence of
the religion through eighteen centuries is adopted as the measure, the
very interests of advocacy themselves require that the best
construction rather than the worst be put upon the errors and
eccentricities of all churches within the compass of Christendom. The
evidences would, in that case, be destroyed by exclusiveness, and
widened in their foundations by comprehensiveness of temper; and
the firmness of every disciple's faith and the energy of his zeal would
become assurances, not of his limitation of mind, but of his largeness
of heart. Instead of endless divisions, multiplied in the search after
unity, we might hope to see the lines of separation become ever
fainter; and every test of Christianity withdrawn except that of moral
sympathy with the spirit of Christ; a test which, as God alone can
apply it, man cannot abuse; and according to which many that, in the
ecclesiastic roll, have been first, shall be last, and the last first.
THE ETHICS OF CHRISTENDOM.
he Temporal Benefits of Christianity exemplified in its Influence on
the Social, Intellectual, Civil, and Political Condition of Mankind,
from its first Promulgation to the present Day. By Robert Blakey.
London. 1849.
mall Books on Great Subjects. Edited by a few Well-Wishers to
Knowledge. No. 19. On the State of Man subsequent to the
Promulgation of Christianity. London. 1851.
he Connection of Morality with Religion; a Sermon, preached in the
Cathedral of St. Patrick, at an Ordination held by the Lord
Archbishop of Dublin, Sunday, September 21, 1851. By William
Fitzgerald, A.M., Vicar of St. Ann's, and Professor of Moral
Philosophy in the University of Dublin. London. 1851.

Of these works, the third treats theoretically, the others practically, of


the relation of Christianity to human nature. The preacher seeks in the
natural conscience for the moral ground and receptacle of revelation;
while the historians trace its moral operation in society and life. Were
both tasks perfectly performed, we should be furnished with a
complete image of the religion at once in its idea and its expression;
should be able definitely to compare its promise with its achievements
and to submit it, as a whole, to philosophical appreciation. But the
two halves of the subject are exhibited with very unequal success. It
is much easier to show the intended than the actual influence of the
Christian faith upon the character of its disciples,—to determine by a
priori methods what it must be, than by an a posteriori induction to
estimate what it has been, and is. Mr. Fitzgerald, as becomes a
professor of ethical science, has well contended that the religion
which he recommends from the pulpit is neither indifferent nor
supercilious towards the morals which he teaches from the University
chair,—but assumes their obligation, appeals to their authority, and, in
its mode of reconciling the human will with the Divine, raises them
into eternal sanctities. It addresses itself to man as a being already
conscious of responsibility; and simply proposes to restore reason and
conscience to that supremacy in fact which of right they can never
lose. How far has this aim been visibly realized? Are the traces of a
Divine renovation clear upon the face of Christendom? Is there the
difference between ancient Greece and modern England, or between
the empire and the papacy of Rome, which might be expected
between an unregenerate world and a regenerate? The historical
answer to these questions is attempted by Mr. Blakey, with perhaps
adequate resources of knowledge, but with so imperfect an
apprehension of the requisites of his argument, that his book, though
often instructive in detail, is altogether ineffective as a whole. He is
content to select and enumerate the most salient and favorable points
in the transition from ancient to modern civilization, and to set them
down to the credit of Christianity; without care to disengage the
action of concurrent causes, or to balance the account by reference to
more questionable effects. A much finer analysis is needed, in order to
draw from history its real testimony on this great matter; and nothing
can well be more arbitrary, than to stroll through some fifteen
centuries, and, gathering up none but the most picturesque and
beneficent phenomena, weave them into a glory to crown the faith
with which they co-exist. In Christendom, all the great and good
things that are done at all will of course be done by Christians, and
will contain such share of the religious element as may belong to the
character of the actor or the age; but before you can avail yourself of
them in Christian Apologetics, it must be shown that, under any other
faith, no social causes would have remained adequate either to
produce them or to provide any worthy equivalent. Because
Charlemagne, after baptizing the Saxons in their own blood, displayed
a better zeal by establishing cathedral and conventual schools,
therefore to put the horn-book of the liberal arts into the hand of his
religion, while leaving the wet sword to stain his own; because
chivalry blended in its vow "fear of God" with "love of the ladies,"
therefore to trace all loyalty and courtesy to the doctrine of the
Church; because the mediæval schoolmen imported into every science
the canons of Divinity, and decided between Realism and Nominalism
on eucharistic principles, therefore to give the priesthood all the
honors of modern philosophy and intellectual liberty,—is, to say the
least, very vulnerable logic and very superficial history. Of a far
superior order is the little book "On the State of Man subsequent to
the Promulgation of Christianity." In a previous treatise, "On the State
of Man before the Promulgation of Christianity," the author had
passed under rapid review the ancient systems of civilization,—
stationary, progressive, aggressive; and having seized on their
characteristic features, he now brings with him determinate points of
comparison into his survey of the post-Apostolic times. The view
which he spreads beneath your eye of the world, as it lay ready to
afford a channel for the Christian faith, is remarkable for breadth and
truth. Conducting you, with the wide picture in your mind, to the pure
head-spring in Galilee, and keeping close to the stream as it descends
and opens from these sequestered heights, he enables you to see,
reach by reach, where it fertilizes and where it destroys; the new
fields of life it enters, the old landmarks of habit it overwhelms. The
author is not more familiar with the Christian Apologists and Fathers,
than with the later Latin and revived Greek literature from Trajan to
Aurelian; and by skilfully noting the moments when Pagan and
Christian life not only stood in silent co-presence, but came into active
contact, he brings out into clear relief the new type of character which
formed itself within the communities of disciples. That type is so
strikingly original, its features so conspicuously express an order of
passions and ideas strange alike to the Hellenic and the Italian races,
as to betray the creative action of some vast moral power unborrowed
from the established civilization. When the free Roman breaks the
bread of communion with slaves,—when the slippery Syrian forswears
lying and theft,—when the heedless Greek changes his eagerness of
the moment into a living for eternity,—when a people ignorant of Stoic
maxims display a contempt of torture and death sublimer than the
ideal of the Porch,—an influence is plainly at work which has
penetrated to hitherto unawakened depths of the human soul. The
phenomenon is the more impressive, when regard is had to the
materials from which the early Christian communities were gathered.
It cannot be imagined that they were composed of elements
particularly choice; and, indeed, amid the universal corruption of
morals and exhaustion of wholesome life, it is difficult to conceive
how, if the Christian doctrine had enforced a rigorous selection,
instead of indiscriminately inviting innocence and guilt, any decent
elements could have been collected. Without adopting Gibbon's
contemptuous estimate of the body of primitive believers, we cannot
doubt that it comprised very mixed ingredients; we know that it
contained great numbers of the servile class, and very few whose
station and culture gave them access to the higher ideas familiar to
the schools of philosophy: yet from these unpromising sources arose a
society, which, in severity of morals, in intensity of affection, in
heroism of endurance, reversed the habits of the world to which they
belonged. It seems to us an idle question for sceptical criticism to
raise, whether the religion of Christ comprised in its teachings any
ethical element absolutely new. If genius had conceived it all before,
life had not produced it till now; and the more you affirm the
philosophers' competency to think it, the more do you convict them of
inability to realize it. But in morals scarcely can there be clear
intellectual conception of principles not yet embodied in living
character. As in the highest works of art, the thing seen is far other
than the thing imagined and described; not doctrines, but persons,
are here the only expression of the truth; and till they appear, ethical
forms are but as the human clay without the vital fire. In the
statement of thought, the early Christians, not excepting the Scripture
writers, are rude and unskilled; and a taste formed from the study of
Plato and Seneca may be offended by the rusticity of Mark, and the
abruptness of Paul. But whoever can rise above the level of a merely
intellectual critique, and embrace, with our anonymous author, the
whole phenomenon of the first centuries of our era, will see a glow of
self-denying faith, and a deep movement of conscience, affording
manifest announcement of a new edition of human nature.
That edition has now been extant for many centuries; and is variously
legible in the literature, the institutions, the private manners of
Christendom. The Christian ideal of human life lies as an open book
before us; yet as a book so various in its versions, and so overlaid
with comments, that the fresh flavor of its language, and even the
finer essence of its thought, are in danger of being lost. The actual
Christianity of each successive age, and each contemporary nation, is
the express result, not only in its dogma, but in its life, of two
component terms,—a given matter, and a given faculty of faith.
However full and constant the former may be in itself, the latter is
perpetually variable with the knowledge and passions of the time, and
the special genius of individual leaders; nor can this variation of
insight in the mind fail to neutralize some portion of truth, and to give
disproportionate magnitude to others. The data supplied by inspiration
itself form no exception to this rule. Delivered into the charge of the
human soul, they fall into the moulds of its recipient nature, take their
immediate form from the laws of its life, and are reacted on from its
independent activity. The immutable custody of anything by a finite
thinking subject, involves the most evident contradiction; the very
contact with human intelligence reduces universal truth to partial, the
permanent to the variable, the secure to the contingent. It is only in
the essential Unity of Reason and Conscience in every age, that we
find the means of correcting the aberrations and verifying the insight
of all particular men. Not that we are to conceive of the human race
collectively as one large person, of which individual minds are vital
organs, and which has a necessary growth and development, entitling
each century to boast of advance beyond its predecessors. We know
of no spiritual units, of no personalities, except each single and
separate will; nor do we find anything in their mutual relation which
necessarily determines them to uninterrupted improvement, and
excludes the encroachment of degeneracy and falsehood. Indeed, no
sorrier product is there of human conceit and ignorance than the cant
of "progress," which assumes that every newest phase of thought is
wisest. But if all men are endowed with radically the same faculties,
however various in their intensities and proportions, there is a court of
appeal in permanent sitting, where the normal laws of intellectual and
moral apprehension are administered against all provincial prejudices
and transient verdicts of error. In the long run, the healthy perceptions
of good eyes will outvote the discoloring effects of all ophthalmic
epidemics, how obstinate and wide soever they may be. And the
moral vision of mankind will no less vindicate its natural rights, by
returning again and again into clear discernments, and settled
admirations, and discharging the illusory forms and false tints of each
separate age. To deny the ethical competency of the mind for this
office,—to say that there is no power given for deciding what, among
the claimants on reverence, is really noble, true, and good,—is, with
all its pietistic pretences, an act of the profoundest scepticism,
washing away, as a quicksand, the only rock on which any faith can be
built. It is to treat the durable source of truth as evanescent and
uncertain, and shut out the possibility of all religion. On the other
hand, to set up and idolize the life and thought of any one time as an
unquestionable rule for all times, and stereotype it for unmodified
reproduction, is to treat the evanescent as the durable, and build on
whatever stands above the water, heedless whether it be the
quicksand or the rock. Yet, strange to say, this particular superstition,
and that general unbelief,—an apparent antithesis of error,—usually
meet in the same mind, and constitute together the chief theology of
most visible churches. Having deposed and insulted the eternal
sanctities, they coax and flatter the letter of Scripture to accept the
vacant throne, and exchange the holy modesty of its administration
for a universal empire of pretence. They drain off the springs of
inspiration at their fountain-head, and turn all history into a plain of
sand, that they may magnify their Hebrew reservoir as the world's
sole supply; forgetting that, when cut off from the running waters, the
choicest store loses its fresh virtues, and the fairest lake, shut up
without exit, turns into a Dead Sea. In contradiction of both errors, we
shall assume that transitory elements cannot fail to mix themselves
with the expression of the purest inspiration,—the horizon of human
relations and expressible things around even the divinest soul being
limited; and that, as the inspiration tries itself upon age after age,
bringing into distinct consciousness now one side of truth and now
another, it becomes more and more possible to find its essence and
eliminate its accidents, to save its catholic beauties apart from its
sectional distortions. The Christian ideal of life is not to be looked for
in what is special to the Crusader or the Quaker,—to Puritan or
Cavalier,—to Platonists of the second century or Aristotelians of the
twelfth,—to Aquinas or Luther,—to John or Paul; but in such sentiment
as was common to them all, and attached to them as citizens of
Christendom. When this element is disengaged from all that
encumbers it, it will be found pervading and animating still whatever
is noblest in our modern life; while all that is narrow, and weak, and
unworthy in the moral doctrine of our age, springs from a forced
attempt to perpetuate the accidental modes of the Apostolic period.
Every one is sensible of a change in the whole climate of thought and
feeling, the moment he crosses any part of the boundary which
divides Christian civilization from Heathendom; yet of nothing is it
more difficult to render any compendious account. It is easy to
enumerate in detail the phenomena which are modified or disappear;
just as on entering a new physical region the travelling naturalist may
register the new species of plants and animals, that, one after
another, present themselves to his research. But these do not paint
the scene before even the learned eye; they are the separate out-
comings of a great life-thrill, into whose current their roots penetrate;
the landscape, as a whole, speaks differently to the mind, and the
whole heaven and earth seem pregnant with a thought unfelt before.
To read off that thought, requires an apprehension the converse of
the analytic vision of science. The same difficulty occurs when we
endeavor to seize the latent principle of a natural realm of history.
Such principle, however, there must be. Beneath all the moving tides
of Christian thought there lie still depths that supply them all, and a
centre of equilibrium around which they sweep. We believe that the
fundamental idea of Christendom may be described to be the ascent
through Conscience into communion with God. Other religions have
lent their sanctions to morality, and announced the Divine commands
to the human will; but only as the laws of an outward monarch within
whose sovereignty we lie, and who, ruling in virtue of his
almightiness, has a right to obedience, ordain as he will. Other
religions, again, have aimed at a union with God. But the conditions of
this union, dictated by misleading conceptions of the Divine nature,
have missed on every side the true level of human dignity and peace.
Manichæism, deifying the antithesis of matter, takes the path of
ascetic suppression of the body. The Indian Pantheist, imagining the
Divine Abyss as the realm of night and infinite negation, strives to
hold in the breath and sink into self-annulment. Plato, seeing in God
the essence of thought, demands science and beauty, not less than
goodness, as the needful notes of harmony with him, and appoints
the approach to heaven by academic ways. The modern Quietists,
worshipping a Being too much the reflection of their own tenderness,
have lost themselves in soft affections, relaxing to the nerves of duty,
and unseemly in the face of eternal law. Christianity alone has neither
crushed the soul by mere submission, like Mohammedanism; nor
melted it away in the tides of infinite being, like Pantheistic faiths; but
has saved the good of both, by establishing the union with God
through a free act of the individual soul. Assigning to him a
transcendent moral nature, sensitive to the same distinctions,
conservative of the same solemnities, which awe and kindle us, it
singles out the conscience as the field where we are to meet him,—
where the bridge will be found of transit between the human and the
divine. No fear or servility remains with an obedience consisting, not
in mystic acts and artificial habits, but in the free play of natural
goodness; and rendered, not in homage to a Supreme Autocrat, but in
sympathy with a Mind itself the infinite impersonation of all the
sanctities. Nor are any dizzy and perilous flights incurred by a
devotion which meets its great Inspirer in no foreign heaven, but in
the higher walks of this home life, and misses him only in what is
mean and low. The place assigned in Christianity to the moral
sentiments and affections has no parallel in any other religion. The
whole faith is as an unutterable sigh after an ideal perfection. Holiness
eternal in heaven, incarnate on earth, and to be realized in men,—this
is the circle of conceptions in which it moves. Its very name for the
Inspiration which mediates all its work, expresses the same thing. It is
not simply an ενθουσιασμος,—not μανια,—not βακχεια,—but the
πνευμα ἁγιον. The Dæmon of Socrates—the least heathenish of
heathen men—was but an intellectual guide, and checked his erring
judgment; the Holy Spirit guards the vigils of duty, and succors the
disciple's tempted will. This profound sense of interior amity with God
through faithfulness to our highest possibility, appears in the Christian
Scriptures under two forms,—the positive and the negative,—each the
complement of the other. In the Gospel, Jesus himself, as befits the
saintly mind lifted above the strife of passion, describes the aspiration
after goodness as the native guidance of the soul to her source and
refuge. In the Epistles, Paul, pouring forth the confessions of a fiery
nature, proclaims the sense of sin to be the contracted hinderance
that bars the ascent, and against which the wings of the struggling
will beat only to grow faint. These representations are evidently but
the two sides of the same doctrine seen from the heavenly and from
the earthly position. Whether we are told what the good heart will
find, or what the guilty must lose, the lesson equally recognizes the
Divine authority of conscience. The benediction and the curse are but
the bright and the dark hemisphere of one perfect truth. The Apostle,
standing in the shadow of the world's night, and regarding its averted
face, dwells on the gloom of alienation,—the "foolish heart that is
darkened,"—the "reprobate mind" from which God is hid. Christ,
conscious of the holy light, and knowing how it penetrates the folds of
willing natures, and wakes what else would sleep, speaks rather of the
glory that is not denied, and utters that deepest of blessings,—"The
pure in heart shall see God." To this bright side also the Pauline view
in the end comes round. For though in him we miss that recognition
of a natural human goodness which gives such grace and sweetness
to many of the parables; though in his scheme the human will has not
only betrayed its trust, but hopelessly crippled its powers; yet he does
not leave it in the collapse of paralysis, with the hard saying that it
can in no wise lift up itself, but points to a hope that bends over it
from above. The soul that is too far gone to act, may still be capable
of love; if unable to trust itself, it may trust another; if it cannot
command its volitions, it may surrender its affections; can reverence,
can aspire, can yield its hand, like a child, to an angel of deliverance.
Beyond the precincts of this world is an Image of divine excellence
and beauty,—one recently withdrawn from human history, and soon to
have a more august return. It is but to turn the eye and give the heart
to that ideal and immortal perfection, and in the light of so pure a
love, the clouds will clear from the conscience, and lift themselves as
a nightmare away; the lame will, forgetting its infirmities, will spring
up and walk; and the restoration, impossible by flight from deformity
and ill, will come through the attraction of a Divine sanctity and
goodness. Thus does the Apostle snatch the disciple at last into the
right perceptions which Christ assumes to be possible at first; and in
both its primitive developments the Christian religion implies the
communion of man with God through purity of heart.
To this sentiment, conveyed with living realization in the person of
Jesus Christ, may be referred whatever is distinctively great in
Christian ethics. Proposing, as an end within their reach, the ascent of
the soul to a divine life, and as the means, a simple surrender to its
own highest intimations, they have melted away the interval between
earthly and heavenly natures,—not by humanizing God, but by
consecrating man. In treating the lower desires of sense and self as
the steams that intercept, the tender reverences as the clear air that
transmits, the light of lights, they have struck the deepest truth of
human consciousness. Hence the temper of aspiration,—the earnest
ideality,—the sense of infinite want, with faith in infinite possibilities,—
the sorrowful unrest in the present, with irrepressible struggle for a
better future,—which are impressed on the poetry, the art, the social
life of Christendom. Unlike the expression of the Hellenic mind, they
are rather a prayer for what might be, than a joy in what is. Hence,
too, the predominance of the psychological and subjective element in
the philosophy of modern times, and the conversion of the ancient
"metaphysics" into the form of "mental science." Man would never
have ceased to be merged in nature, and registered merely as a part
of its contents; his self-knowledge would not have vindicated its
independent rights; his mind would not have been recognized as the
court of record for the moral legislation of the universe,—had not his
religion taken him deep into himself, and from a new point shown him
his relation to all else; kindling his own consciousness to a point of
intense brilliancy, in correspondence with a divine centre, which must
be sought on the same axis of being,—like the two determining foci of
an infinite curve, that find each other out, while the realm of
determined nature lies around, as the configured area, or the
bounding curve. Of the external world, indeed, too little account has
been made in the faith of Christians. They have not cared to recognize
it as the shrine of immanent Deity;—have stood in uneasy relations to
it; often inimical to it; sometimes trying to get rid of it as an illusion;
usually regarding it as a foreign object, like a great statue on the
stage of being, with only stony eyes and ears for the real play of
passions that whirl around. Existence, in its essence, has been felt as
an interview between man and God, at which space and nature have
been collaterally present, but in which it was not apparent what they
had to do. Physical science and the plastic arts may have reason to
complain of the depressing influence of this imperfect view, and of the
hard necessity under which it places them of pursuing their ends with
only scanty and grudging recognition from religion. But, for the
philosophic knowledge of human nature, and the practical regulation
of human society, this isolation of the soul within its own
consciousness,—this concentrated personality,—this vivid interchange
of life with God without diffusion through benumbing media,—must be
held eminently ennobling.
If, from the fundamental Christian sentiment, we descend to the
scheme of Applied Morals which it organized and inspired, the
principle still vindicates itself in its results. The great problems of life
are supplied from two sources,—the Persons that may engage our
affections, and the Pursuits that may invite our will. The light in which
the personal relations are presented before the eye of Christendom is
undeniably benign and true. It has never been obscured without the
social spread of injustice and discontent; nor ever cleared again, but
as the precursor of reformation. That every human soul has its sacred
concerns and its divine communion, is the simplest of thoughts; but
so deep and moving, that, where it is received and acknowledged, it
calls up angelic virtues; where it is insulted and denied, it lets slip
avenging fiends. Wherever it is sincerely held, it secures that
reverential feeling towards others, beneath whose spell the selfish
passions sleep, and without which the precept of courtesy and the
definition of rights are an ineffectual form. Power loses its insolence,
and dependence its sting, where their mutual relation does not carry
the whole individuality with it, but stops with the limits of social and
political convenience, and lies under the restraining protection of a
supreme equality before God. The "Fraternity" that is the offspring of
political theories, and aims to neutralize by fellow-citizenship the
diversities and antipathies of nature, is often the watchword of envy
and egotism, shouted by the voice of hatred, and announcing the
deed of violence. It is for want of faith in that highest brotherhood of
worship and responsibility which Christianity assumes, that impatient
schemes are formed for artificially equalizing the weak and the strong,
and abolishing the relations of necessary dependence. Nor, where that
faith is absent, can they ever be answered so as to satisfy the feeling
from which they spring. They may be shown to be impracticable, and
crushed by the relentless argument of fact; but the fact will be
protested against as unnatural, and the impossibility will seem a
cruelty. How differently is this topic handled by the logic of science
and the sentiment of religion! How much less justly does the former
draw the line between natural subordination among men and
tyrannous oppression, than the latter! Aristotle undertakes the
defence of slavery on grounds both of philosophy and of experience.
Nature, he contends, pursuing a definite end in every act of creation,
assigns to some things, from their very origin, a destiny to rule, while
imposing on others a necessity of being ruled. Wherever a plurality of
parts concur to form a general whole, dominant and subordinate
elements present themselves. Even within the inanimate realm this is
apparent, as in the case of harmony in music. But it is chiefly
conspicuous in the sphere of animal existence; the body being, by
nature, servitor, of which the soul is lord. In the highest stage of
animate being, the constitution of well-organized men, this law comes
into the clearest light; for here the soul sways the body with absolute
command, while reason exercises over the passions the prerogatives
of a royal and constitutional power; and were equality to be
substituted for these modes of subjection, mischief would ensue on all
sides. Not less evidently does Nature announce the dependence of
inferior on superior in the rank allotted to the brutes in relation to
man; and again, in the case of the two sexes, of which the male, as
the more distinguished, is rendered dominant. The same necessary
law adjusts the positions of mankind inter se. All those who are as
intrinsically inferior to their neighbors as the body to the soul, or the
brute to the man,—(and this is precisely the case of the mere manual
laborer,)—are slaves by nature; and for them, as for the body and the
Welcome to our website – the ideal destination for book lovers and
knowledge seekers. With a mission to inspire endlessly, we offer a
vast collection of books, ranging from classic literary works to
specialized publications, self-development books, and children's
literature. Each book is a new journey of discovery, expanding
knowledge and enriching the soul of the reade

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.

Let us accompany you on the journey of exploring knowledge and


personal growth!

textbookfull.com

You might also like