| |
| |
About the Author | |
| |
| |
Introduction | |
| |
| |
| |
Installing Python | |
| |
| |
Which Python Is Right for You? | |
| |
| |
Python on Windows | |
| |
| |
Python on Mac OS X | |
| |
| |
Python on Mac OS 9 | |
| |
| |
Python on RedHat Linux | |
| |
| |
Python on Debian GNU/Linux | |
| |
| |
Python Installation from Source | |
| |
| |
The Interactive Shell | |
| |
| |
Summary | |
| |
| |
| |
Your First Python Program | |
| |
| |
Diving In | |
| |
| |
Declaring Functions | |
| |
| |
Documenting Functions | |
| |
| |
Everything Is an Object | |
| |
| |
Indenting Code | |
| |
| |
Testing Modules: The if name Trick | |
| |
| |
Summary | |
| |
| |
| |
Native Datatypes | |
| |
| |
Introducing Dictionaries | |
| |
| |
Introducing Lists | |
| |
| |
Introducing Tuples | |
| |
| |
Declaring Variables | |
| |
| |
Formatting Strings | |
| |
| |
Mapping Lists | |
| |
| |
Joining Lists and Splitting Strings | |
| |
| |
Summary | |
| |
| |
| |
The Power of Introspection | |
| |
| |
Diving In | |
| |
| |
Using Optional and Named Arguments | |
| |
| |
Using type, str, dir, and Other Built-in Functions | |
| |
| |
Getting Object References with getattr | |
| |
| |
Filtering Lists | |
| |
| |
Understanding the Peculiar Nature of and and or | |
| |
| |
Using lambda Functions | |
| |
| |
Putting It All Together | |
| |
| |
Summary | |
| |
| |
| |
Objects and Object-Orientation | |
| |
| |
Diving In | |
| |
| |
Importing Modules Using from module import | |
| |
| |
Defining Classes | |
| |
| |
Instantiating Classes | |
| |
| |
Exploring UserDict: A Wrapper Class | |
| |
| |
Using Special Class Methods | |
| |
| |
Introducing Class Attributes | |
| |
| |
Using Private Functions | |
| |
| |
Summary | |
| |
| |
| |
Exceptions and File Handling | |
| |
| |
Handling Exceptions | |
| |
| |
Working with File Objects | |
| |
| |
Iterating with for Loops | |
| |
| |
Using sys.modules | |
| |
| |
Working with Directories | |
| |
| |
Putting It All Together | |
| |
| |
Summary | |
| |
| |
| |
Regular Expressions | |
| |
| |
Diving In | |
| |
| |
Case Study: Street Addresses | |
| |
| |
Case Study: Roman Numerals | |
| |
| |
Verbose Regular Expressions | |
| |
| |
Case Study: Parsing Phone Numbers | |
| |
| |
Summary | |
| |
| |
| |
HTML Processing | |
| |
| |
Diving In | |
| |
| |
Introducing Python's sgmllib.py | |
| |
| |
Extracting Data from HTML Documents | |
| |
| |
Understanding locals() and globals() | |
| |
| |
Using Dictionary-based String Formatting | |
| |
| |
Quoting Attribute Values | |
| |
| |
Parsing HTML One Tag at a Time | |
| |
| |
Putting It All Together | |
| |
| |
Summary | |
| |
| |
| |
XML Processing | |
| |
| |
Diving In | |
| |
| |
Importing Python Packages | |
| |
| |
Parsing XML | |
| |
| |
Dealing with Unicode | |
| |
| |
Searching for XML Elements | |
| |
| |
Accessing XML Element Attributes | |
| |
| |
Summary | |
| |
| |
| |
Scripts and Streams | |
| |
| |
Abstracting Input Sources | |
| |
| |
Using Standard Input, Output, and Error | |
| |
| |
Introducing Some XML Processing Techniques | |
| |
| |
Handling Command-Line Arguments | |
| |
| |
Putting It All Together | |
| |
| |
Summary | |
| |
| |
| |
HTTP Web Services | |
| |
| |
Diving In | |
| |
| |
How Not to Fetch Data Over HTTP | |
| |
| |
Supporting HTTP Features | |
| |
| |
Debugging HTTP Web Services | |
| |
| |
Setting the User-Agent | |
| |
| |
Handling Last-Modified and ETag | |
| |
| |
Handling Redirects | |
| |
| |
Handling Compressed Data | |
| |
| |
Putting It All Together | |
| |
| |
Summary | |
| |
| |
| |
SOAP Web Services | |
| |
| |
Diving In | |
| |
| |
Installing the SOAP Libraries | |
| |
| |
Taking Your First Steps with SOAP | |
| |
| |
Introducing WSDL | |
| |
| |
Searching Google | |
| |
| |
Troubleshooting SOAP Web Services | |
| |
| |
Summary | |
| |
| |
| |
Unit Testing | |
| |
| |
Diving In | |
| |
| |
Introducing the Test Suite | |
| |
| |
Constructing Test Cases | |
| |
| |
Summary | |
| |
| |
| |
Test-First Programming | |
| |
| |
Diving In (Stage 1) | |
| |
| |
Converting Roman Numerals | |
| |
| |
Converting Roman Numerals, Stage 3 | |
| |
| |
Converting Roman Numerals, Stage 4 | |
| |
| |
Converting Roman Numerals, Stage 5 | |
| |
| |
Summary | |
| |
| |
| |
Refactoring | |
| |
| |
Diving In | |
| |
| |
Handling Changing Requirements | |
| |
| |
Refactoring for Performance | |
| |
| |
Postscript | |
| |
| |
Summary | |
| |
| |
| |
Functional Programming | |
| |
| |
Diving In | |
| |
| |
Finding the Path | |
| |
| |
Filtering Lists Revisited | |
| |
| |
Mapping Lists Revisited | |
| |
| |
Data-centric Programming | |
| |
| |
Dynamically Importing Modules | |
| |
| |
Putting It All Together | |
| |
| |
Summary | |
| |
| |
| |
Dynamic Functions | |
| |
| |
Diving In | |
| |
| |
Pluralizing Nouns | |
| |
| |
Pluralizing Nouns, Stage 2 | |
| |
| |
Pluralizing Nouns, Stage 3 | |
| |
| |
Pluralizing Nouns, Stage 4 | |
| |
| |
Pluralizing Nouns, Stage 5 | |
| |
| |
Pluralizing Nouns, Stage 6 | |
| |
| |
Summary | |
| |
| |
| |
Performance Tuning | |
| |
| |
Diving In | |
| |
| |
Using the timeit Module | |
| |
| |
Optimizing Regular Expressions | |
| |
| |
Optimizing Dictionary Lookups | |
| |
| |
Optimizing List Operations | |
| |
| |
Optimizing String Manipulation | |
| |
| |
Summary | |
| |
| |
| |
Python License | |
| |
| |
| |
History of the Software | |
| |
| |
| |
Terms and Conditions for Accessing or Otherwise Using Python | |
| |
| |
| |
GNU Free Documentation License | |
| |
| |
| |
Preamble | |
| |
| |
| |
Applicability and Definitions | |
| |
| |
| |
Verbatim Copying | |
| |
| |
| |
Copying in Quantity | |
| |
| |
| |
Modifications | |
| |
| |
| |
Combining Documents | |
| |
| |
| |
Collections of Documents | |
| |
| |
| |
Aggregation with Independent Works | |
| |
| |
| |
Translation | |
| |
| |
| |
Termination | |
| |
| |
| |
Future Revisions of This License | |
| |
| |
Addendum: How to Use This License for Your Documents | |
| |
| |
Index | |