一、目录介绍
Preface
Part Ⅰ.The Beginning
1.A Sneak Preview
“Programming Python: The Short Story”
The Task
Step 1: Representing Records
Using Lists
Using Dictionaries
Step 2: Storing Records Persistently
Using Formatted Files
Using Pickle Files
Using Per-Record Pickle Files
Using Shelves
Step 3: Stepping Up to OOP
Using Classes
Adding Behavior
Adding Inheritance
Refactoring Code
Adding Persistence
Other Database Options
Step 4: Adding Console Interaction
A Console Shelve Interface
Step 5: Adding a GUI
GUI Basics
Using OOP for GUIs
Getting Input from a User
A GUI Shelve Interface
Step 6: Adding a Web Interface
CGI Basics
Running a Web Server
Using Query Strings and urllib
Formatting Reply Text
A Web-Based Shelve Interface
The End of the Demo
Part Ⅱ.System Programming
2.System Tools
“The os.path to Knowledge”
Why Python Here?
The Next Five Chapters
System Scripting Overview
Python System Modules
Module Documentation Sources
Paging Documentation Strings
A Custom Paging Script
String Method Basics
Other String Concepts in Python 3.X: Unicode and bytes
File Operation Basics
Using P'rograms in Two Ways
Python Library Manuals
Commercially Published References
Inrroducing the sys Module
Platforms and Versions
The Module Search Path
The Loaded Modules Table
Exception Details
Other sys Module Exports
Introducing the os Module
Tools in the os Module
Administrative Tools
Portability Constants
Common os.path Tools
Running Shell Commands from Scripts
Other os Module Exports
3.Script Execution Context
“I’d Like to Have an Argument, Please”
Current Working Directory
CWD, Files, and Import Paths
CWD and Command Lines
Thread Exits and Shared State
Interprocess Communication
Anonymous Pipes
Named Pipes (Fifos)
Sockets: A First Look
Signals
The multiprocessing Module
Why multiprocessing?
The Basics: Processes and Locks
IPC Tools: Pipes, Shared Memory, and Queues
Starting Independent Programs
And Much More
Why multiprocessing? The Conclusion
Other Ways to Start Programs
The os.spawn Calls
The os.startfile call on Windows
A Portable Program-Launch Framework
Other System Tools Coverage
Command-Line Arguments
Parsing Command-Line Arguments
Shell Environment Variables
Fetching Shell Variables
Changing Shell Variables
Shell Variable Fine Points: Parents, putenv, and getenv
Standard Streams
Redirecting Streams to Files and Programs
Redirected Streams and User Interaction
Redirecting Streams to Python Objects
The io.StringIO and io.Bytesl0 Utility Classes
Capturing the stderr Stream
Redirection Syntax in Print Calls
Other Redirection Options: os.popen and subprocess Revisited
4.File and Directory Tools
“Erase Your Hard Drive in Five Easy Steps!”
File Tools
The File Object Model in Python 3,X
Using Built-in File Objects
Binary and Text Files
Lower-Level File Tools in the os Module
File Scanners
Directory Tools
Walking One Directory
Walking Directory Trees
Handling Unicode Filenames in 3.X: listdir, walk, glob
5.Parallel System Tools
“Telling the Monkeys What to Do”
Forking Processes
The fork/exec Combination
Threads
The _thread Module
The threading Module
The queue Module
Preview: GUIs and Threads
More on the Globallnterpreter Lock
Program Exits
sys Module Exits
os Module Exits
Shell Command Exit Status Codes
Process Exit Status and Shared State
Thread Exits and Shared State
Interprocess Communication
Anonymous Pipes
Named Pipes (Fifos)
Sockets: A First Look
Signals
The multiprocessing Module
Why multiprocessing?
The Basics: Processes and Locks
IPC Tools: Pipes, Shared Memory, and Queues
Starting Independent Programs
And Much More
Why multiprocessing? The Conclusion
Other Ways to Start Programs
The os.spawn Calls
The os.startfile call on Windows
A Portable Program-Launch Framework
Other System Tools Coverage
6.Complete System Programs
“The Greps of Wrath”
A Quick Game of “Find the Biggest Python File”
Scanning the Standard Library Directory
Scanning the Standard Library Tree
Scanning the Module Search Path
Scanning the Entire Machine
Printing Unicode Filenames
Splitting and Joining Files
Splitting Files Portably
Joining Files Portably
Usage Variations
Generating Redirection Web Pages
Page Template File
Page Generator Script
A Regression Test Script
Running the Test Driver
Copying Directory Trees
Comparing Directory Trees
Finding Directory Differences
Finding Tree Differences
Running the Script
Verifying Backups
Reporting Differences and Other Ideas
Searching Directory Trees
Greps and Globs and Finds
Rolling Your Own find Module
Cleaning Up Bytecode Files
A Python Tree Searcher
Visitor: Walking Direcror/es “++”
Editing Files in Directory Trees (Visitor)
Global Replacements in Directory Trees (Visitor)
Counting Source Code Lines (Visitor)
Recoding Copies with Classes (Visitor)
Other Visitor Examples (External)
Playing Media Files
The Python webbrowser Module
The Python mimetypes Module
Running the Script
Automated Program Launchers (External)
……
Part Ⅲ.GUI Programming
Part Ⅳ.Internet Programming
Part Ⅴ.Tools and Techniques
Part Ⅵ.The End
Index