| Acknowledgments | xxiii |
| Introduction | xxv |
Part I | Fundamentals of the Language | |
1 | Introducing Python | 3 |
| What Is Python? | 4 |
| What Is Python Good For? | 6 |
| What Isn't Python Good For? | 9 |
| Who Uses Python? | 9 |
| Python History | 10 |
| Similar Languages | 12 |
2 | Python Fundamentals | 19 |
| Executing Python Programs | 20 |
| Script, Program, or Module? | 31 |
3 | Components of a Python Program | 33 |
| Built-in Object Types | 34 |
| Statements | 69 |
4 | Functions | 81 |
| Function Definition and Execution | 83 |
| Scoping | 84 |
| Arguments | 88 |
| Return Values | 95 |
| Advanced Function Calling | 96 |
5 | Modules | 101 |
| Importing a Module | 102 |
| Tricks for Importing Modules | 106 |
| Packages | 109 |
| Creating a Module | 111 |
6 | Object Orientation | 113 |
| Creating a Class | 114 |
7 | Exceptions and Error Trapping | 125 |
| What Is an Exception? | 127 |
| What Happens When an Exception Occurs? | 128 |
| Exception Handling | 131 |
| Built-In Exceptions | 138 |
| Rolling Your Own Exceptions | 144 |
Part II | Applying the Python Libraries | |
8 | Python's Built-In Functions | 149 |
9 | Interfacing to the OS | 169 |
| Working with the System (sys Module) | 170 |
| Working with the Operating System (os Module) | 176 |
| Multithreading | 191 |
10 | Processing Information | 207 |
| Manipulating Numbers | 208 |
| Text Manipulation | 214 |
| Time | 232 |
| Data Types and Operators | 239 |
| Unicode Strings | 247 |
11 | Working with Files | 257 |
| File Processing | 258 |
| Controlling File I/O | 266 |
| Getting File Lists | 269 |
| Basic File/Directory Management | 270 |
| Access and Ownership | 272 |
| Manipulating File Paths | 275 |
12 | Data Management and Storage | 277 |
| Managing Internal Structures | 278 |
| Object Persistence | 281 |
13 | Communicating over a Network | 289 |
| Networking 101 | 290 |
| Obtaining Networking Information | 294 |
| Basic Socket Functions | 295 |
| Creating a Network Server | 302 |
| Client Modules | 307 |
| Handling Internet Data | 314 |
14 | Using Python for Multimedia | 329 |
| Audio Modules | 330 |
| Graphics Modules | 345 |
15 | Interface Building with Tk | 351 |
| Installing Python/Tk under Unix | 353 |
| Installing Python/Tk under Windows | 354 |
| Installing Python/Tk under MacOS | 354 |
| Introduction to Tk | 354 |
| Using Widgets | 361 |
| Controlling Window Geometry | 388 |
Part III | Application Development | |
16 | Using Python as a RAD Tool | 395 |
| What RAD Really Is | 396 |
| Why Python? | 400 |
17 | Application Development with Python | 405 |
| Integrated Development Environments | 406 |
| Python Standard Library | 413 |
| Vaults of Parnassus | 420 |
| Zope and Jython | 420 |
18 | Distributing Python Modules | 421 |
| Using distutils | 423 |
| Future Features | 424 |
Part IV | Web Development | |
19 | Web Development Basics | 427 |
| Writing HTML | 428 |
| Uniform Resource Locators | 430 |
| Dynamic Websites Using CGI | 432 |
| Cookies | 448 |
| Security | 451 |
20 | Standard Markup Language Processing | 453 |
| Processing SGML | 455 |
| Processing HTML | 455 |
| Processing XML | 460 |
21 | Other Python Web Tools | 471 |
| Zope, the Z-Objects Publishing Environment | 472 |
| Jython | 475 |
| Python.NET | 478 |
| Python Server Pages | 479 |
| Python and ActiveScript | 480 |
| Mailman | 480 |
| Grail | 481 |
| Apache and Python | 481 |
| SocketServer and BaseHTTPServer | 482 |
| Medusa | 483 |
Part V | Cross-platform Development | |
22 | Paths to Cross-platform Development | 487 |
| Basic Platform Support | 488 |
| Execution Environment | 489 |
| Line Termination | 497 |
| Character Sets | 498 |
| Files and Pathnames | 499 |
| Data Differences | 499 |
| Performance and Resources | 500 |
Part VI | Inside Python | |
23 | The Python Architecture | 503 |
| Namespaces, Code Blocks, and Frames | 505 |
| Built-in Types | 509 |
| Bytecode | 517 |
24 | Debugging and Tuning | 533 |
| An Introduction to Debugging | 534 |
| Debugging Techniques | 542 |
| Optimizing Python Applications | 556 |
25 | Documenting and Documentation | 567 |
| Comments | 568 |
| Embedded Document Strings | 571 |
| Translating Embedded Strings into Documentation | 573 |
26 | Extending Python | 581 |
| Basic Interface | 582 |
| Data Conversion | 589 |
| Managing Reference Counts | 592 |
| Exceptions | 594 |
| Low-Level Object Access | 600 |
| Where Next? | 609 |
27 | Embedding Python | 611 |
| Embedding Principles | 612 |
| Python Embedding Types | 620 |
| Where Next? | 629 |
A | Python Library Guide | 631 |
B | Python Resources | 659 |
| Web Resources | 660 |
| Email, Newsgroup, and Mailing List Resources | 663 |
| Online Documentation | 664 |
| Print Resources | 665 |
| Index | 667 |