Book description
If you've mastered Python's fundamentals, you're ready to start using it to get real work done. Programming Python will show you how, with in-depth tutorials on the language's primary application domains: system administration, GUIs, and the Web. You'll also explore how Python is used in databases, networking, front-end scripting layers, text processing, and more. This book focuses on commonly used tools and libraries to give you a comprehensive understanding of Python’s many roles in practical, real-world programming.
You'll learn language syntax and programming techniques in a clear and concise manner, with lots of examples that illustrate both correct usage and common idioms. Completely updated for version 3.x, Programming Python also delves into the language as a software development tool, with many code examples scaled specifically for that purpose.
Topics include:
- Quick Python tour: Build a simple demo that includes data representation, object-oriented programming, object persistence, GUIs, and website basics
- System programming: Explore system interface tools and techniques for command-line scripting, processing files and folders, running programs in parallel, and more
- GUI programming: Learn to use Python’s tkinter widget library
- Internet programming: Access client-side network protocols and email tools, use CGI scripts, and learn website implementation techniques
- More ways to apply Python: Implement data structures, parse text-based information, interface with databases, and extend and embed Python
Table of contents
- A Note Regarding Supplemental Files
- Preface
- I. The Beginning
-
II. System Programming
- 2. System Tools
-
3. Script Execution Context
- âIâd Like to Have an Argument, Pleaseâ
- Current Working Directory
- Command-Line Arguments
- Shell Environment Variables
- Standard Streams
-
4. File and Directory Tools
- âErase Your Hard Drive in Five Easy Steps!â
- File Tools
- Directory Tools
-
5. Parallel System Tools
- âTelling the Monkeys What to Doâ
- Forking Processes
- Threads
- Program Exits
- Interprocess Communication
- The multiprocessing Module
- Other Ways to Start Programs
- 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â
- Splitting and Joining Files
- Generating Redirection Web Pages
- A Regression Test Script
- Copying Directory Trees
- Comparing Directory Trees
- Searching Directory Trees
- Visitor: Walking Directories â++â
- Playing Media Files
- Automated Program Launchers (External)
-
III. GUI Programming
-
7. Graphical User Interfaces
- âHereâs Looking at You, Kidâ
- Python GUI Development Options
- tkinter Overview
- Climbing the GUI Learning Curve
- tkinter Coding Alternatives
- Adding Buttons and Callbacks
- Adding User-Defined Callback Handlers
- Adding Multiple Widgets
- Customizing Widgets with Classes
- Reusable GUI Components with Classes
- The End of the Tutorial
- Python/tkinter for Tcl/Tk Converts
-
8. A tkinter Tour, Part 1
- âWidgets and Gadgets and GUIs, Oh My!â
- Configuring Widget Appearance
- Top-Level Windows
- Dialogs
- Binding Events
- Message and Entry
- Checkbutton, Radiobutton, and Scale
- Running GUI Code Three Ways
- Images
- Viewing and Processing Images with PIL
-
9. A tkinter Tour, Part 2
- âOn Todayâs Menu: Spam, Spam, and Spamâ
- Menus
- Listboxes and Scrollbars
- Text
- Canvas
- Grids
- Time Tools, Threads, and Animation
- The End of the Tour
-
10. GUI Coding Techniques
- âBuilding a Better Mousetrapâ
- GuiMixin: Common Tool Mixin Classes
- GuiMaker: Automating Menus and Toolbars
- ShellGui: GUIs for Command-Line Tools
- GuiStreams: Redirecting Streams to Widgets
- Reloading Callback Handlers Dynamically
- Wrapping Up Top-Level Window Interfaces
- GUIs, Threads, and Queues
- More Ways to Add GUIs to Non-GUI Code
- The PyDemos and PyGadgets Launchers
-
11. Complete GUI Programs
- âPython, Open Source, and Camarosâ
-
PyEdit: A Text Editor Program/Object
- Running PyEdit
- PyEdit Changes in Version 2.0 (Third Edition)
- PyEdit Changes in Version 2.1 (Fourth Edition)
- PyEdit Source Code
- PyPhoto: An Image Viewer and Resizer
- PyView: An Image and Notes Slideshow
- PyDraw: Painting and Moving Graphics
- PyClock: An Analog/Digital Clock Widget
- PyToe: A Tic-Tac-Toe Game Widget
- Where to Go from Here
-
7. Graphical User Interfaces
-
IV. Internet Programming
-
12. Network Scripting
- âTune In, Log On, and Drop Outâ
- Python Internet Development Options
- Plumbing the Internet
- Socket Programming
-
Handling Multiple Clients
-
Forking Servers
- Running the forking server
- Other run modes: Local servers with Cygwin and remote clients
- Forked processes and sockets
- Exiting from children
- Killing the zombies: Donât fear the reaper!
- Preventing zombies with signal handlers on Linux
- Why multiprocessing doesnât help with socket server portability
- Threading Servers
- Standard Library Server Classes
- Multiplexing Servers with select
- Summary: Choosing a Server Scheme
-
Forking Servers
- Making Sockets Look Like Files and Streams
- A Simple Python File Server
-
13. Client-Side Scripting
- âSocket to Me!â
- FTP: Transferring Files over the Net
- Transferring Files with ftplib
- Transferring Directories with ftplib
- Transferring Directory Trees with ftplib
- Processing Internet Email
- POP: Fetching Email
- SMTP: Sending Email
-
email: Parsing and Composing Mail Content
- Message Objects
- Basic email Package Interfaces in Action
-
Unicode, Internationalization, and the Python 3.1 email
Package
- Parser decoding requirement
- Text payload encodings: Handling mixed type results
- Text payload encodings: Using header information to decode
- Message header encodings: email package support
- Message address header encodings and parsing, and header creation
- Workaround: Message text generation for binary attachment payloads is broken
- Workaround: Message composition for non-ASCII text parts is broken
- Summary: Solutions and workarounds
- A Console-Based Email Client
- The mailtools Utility Package
- NNTP: Accessing Newsgroups
- HTTP: Accessing Websites
- The urllib Package Revisited
- Other Client-Side Scripting Options
-
14. The PyMailGUI Client
- âUse the Source, Lukeâ
- Major PyMailGUI Changes
-
A PyMailGUI Demo
- Getting Started
- Loading Mail
- Threading Model
- Load Server Interface
- Offline Processing with Save and Open
- Sending Email and Attachments
- Viewing Email and Attachments
- Email Replies and Forwards and Recipient Options
- Deleting Email
- POP Message Numbers and Synchronization
- Handling HTML Content in Email
- Mail Content Internationalization Support
- Alternative Configurations and Accounts
- Multiple Windows and Status Messages
-
PyMailGUI Implementation
- PyMailGUI: The Main Module
- SharedNames: Program-Wide Globals
- ListWindows: Message List Windows
- ViewWindows: Message View Windows
- messagecache: Message Cache Manager
- popuputil: General-Purpose GUI Pop Ups
- wraplines: Line Split Tools
- html2text: Extracting Text from HTML (Prototype, Preview)
- mailconfig: User Configurations
- textConfig: Customizing Pop-Up PyEdit Windows
- PyMailGUIHelp: User Help Text and Display
- altconfigs: Configuring for Multiple Accounts
- Ideas for Improvement
-
15. Server-Side Scripting
- âOh, What a Tangled Web We Weaveâ
- Whatâs a Server-Side CGI Script?
- Running Server-Side Examples
- Climbing the CGI Learning Curve
- Saving State Information in CGI Scripts
- The Hello World Selector
- Refactoring Code for Maintainability
- More on HTML and URL Escapes
- Transferring Files to Clients and Servers
- 16. The PyMailCGI Server
-
12. Network Scripting
-
V. Tools and Techniques
-
17. Databases and Persistence
- âGive Me an Order of Persistence, but Hold the Picklesâ
- Persistence Options in Python
- DBM Files
- Pickled Objects
- Shelve Files
- The ZODB Object-Oriented Database
- SQL Database Interfaces
- ORMs: Object Relational Mappers
- PyForm: A Persistent Object Viewer (External)
- 18. Data Structures
- 19. Text and Language
-
20. Python/C Integration
- âI Am Lost at Câ
- Extending Python in C: Overview
- A Simple C Extension Module
- The SWIG Integration Code Generator
- Wrapping C Environment Calls
- Wrapping C++ Classes with SWIG
- Other Extending Tools
- Embedding Python in C: Overview
- Basic Embedding Techniques
- Registering Callback Handler Objects
- Using Python Classes in C
- Other Integration Topics
-
17. Databases and Persistence
-
VI. The End
-
21. Conclusion: Python and the Development Cycle
- âThatâs the End of the Book, Now Hereâs the Meaning of Lifeâ
- âSomethingâs Wrong with the Way We Program Computersâ
- The âGilligan Factorâ
- Doing the Right Thing
- Enter Python
- But What About That Bottleneck?
- On Sinking the Titanic
- âSo Whatâs Python?â: The Sequel
- In the Final Analysisâ¦
-
21. Conclusion: Python and the Development Cycle
- Index
- About the Author
- Colophon
- Copyright
Product information
- Title: Programming Python, 4th Edition
- Author(s):
- Release date: December 2010
- Publisher(s): O'Reilly Media, Inc.
- ISBN: 9780596158101
You might also like
book
Hands-On Machine Learning with Scikit-Learn, Keras, and TensorFlow, 3rd Edition
Through a recent series of breakthroughs, deep learning has boosted the entire field of machine learning. …
book
Hands-On Machine Learning with Scikit-Learn, Keras, and TensorFlow, 2nd Edition
Through a series of recent breakthroughs, deep learning has boosted the entire field of machine learning. …
book
Python Workout
Python Workout presents 50 exercises that focus on key Python 3 features. In it, expert Python …
book
Robust Python
Does it seem like your Python projects are getting bigger and bigger? Are you feeling the …