Programming Python
Programming Python Object-Oriented Scripting

By Mark Lutz

Cover | Table of Contents | Index | Colophon


Table of Contents

Foreword

Preface

PART 1: Introducing Python

Chapter 1. So What's Python?
   "And Now for Something Completely Different"
   The Life of Python
   What's All the Excitement About?
   The Compulsory Features List
   What's Python Good For?
   What's Python Not Good For?

Chapter 2. A Sneak Preview
   "Put Your Code Where Your Mouth Is"
   Shell Tools Programming
   Graphical User Interfaces
   Data Structure Libraries
   Persistent Information
   Processing Text-Based Information
   Extension Language Programming
   And Whatever Else You Want to Use It For
   Conclusion

Chapter 3. Getting Started
   "Scenes from Life in the Real World"
   Configuring Your Environment
   Installing Python
   And If All Else Fails
   Using the Command-Line Interpreter
   Using the Python Command Line
   Platforms Supported Today
   What's Next?
   Conclusion

PART 2: Language Fundamentals

Chapter 4. Writing Basic Shell Tools
   It Was a Dark and Stormy Night...
   "Quick and Dirty" File Packing
   Dissecting the Code
   New Language Concepts
   "Telling the Monkeys What to Do"

Chapter 5. Variations on a Theme
   "How Shall I Code Thee? Let Me Count the Ways"
   Packing With File Methods
   Packing with Explicit Files
   Packing with Counter Loops
   Unpacking with Explicit Files
   Unpacking with Line-by-Line Input
   Unpacking Without File Methods
   Crunching the Code (to Death)

Chapter 6. Adding a Functional Interface
   "The Packing Scripts Go Public"
   Part 1: "The Middleman"
   Part 2: "The Unpacker on Steroids"
   Part 3: "The Packer Hits the Big Time"
   Building Systems with Functions

Chapter 7. Adding a Simple User Interface
   "Go Ahead--Reuse My Software"
   Running Scripts Versus Calling Functions
   Running the Interface in batch Mode
   Building Systems with Modules

Chapter 8. Adding Text-Based Menus
   "On Today's Menu: Packing, Unpacking, and Fresh Spam"
   Making Menus with Dictionaries
   Making Menus with Lists
   Built-In Types: Operators, Methods, and Modules
   The Zen of Python: Namespaces are Dictionaries
   Dictionaries and Keyword Arguments
   Design Concepts: Do Modules Support OOP?

Chapter 9. Moving Menus to Classes
   "Here's Your Script. Here's Your Script on OOP. Any Questions?"
   A First Attempt: Generalized Menu Functions
   So Who Needs Classes?
   OOP in Action: Menus as Classes
   Exploring Python Classes
   Configuring Menu Data
   Namespaces, Part 3: Classes and Instances
   More on Zen: Class and Instance Namespace Dictionaries
   Design Concepts: Implementing Generic Functions

Chapter 10. More Class Magic
   More Bells, Whistles, and Little Blinking Lights
   Deriving Menus from Simpler User Interaction
   A Simple User-Interface Subclass: Back to Where We Started?
   A Menu-Interface Subclass: Registering Methods
   Inheriting from More than One Class
   More on Exception Handling: Exception Lists
   Making Menus Expandable: Overloading Operators
   Summary: Python and the OOP Trinity
   Design Exercise: Adding Logging and Security Extensions
   Where's the Beef?
   Conclusion
   Welcome to the Middle of the Book!
   A Quick Summary of Topics We've Covered So Far
   Plus a Few Shell Tool Tricks
   Python in a Nutshell
   What's Next?
   Brewing Python tee

PART 3: Tools and Applications

Chapter 11. Graphical User Interfaces
   "Here's Looking at You, Kid"
   Climbing the GUI Learning Curve
   Automating GUI Construction
   Case Study: "The Packer Goes GUI!"
   Avoiding Namespace Clashes
   Handling Program Errors
   A Totally RAD Language
   Other Tkinter Topics
   Summary

Chapter 12. Persistent Information
   "Give Me an Order of Persistence, But Hold the Pickles"
   Case Study: a Table Browser GUI
   Other Persistence Topics
   Summary

Chapter 13. Implementing Objects
   "Roses are Red, Violets are Blue; Lists are Mutable, and So is Class Foo"
   Implementing Stacks
   Implementing Sets
   Classical Data Structures in Python

Chapter 14. Extending Python
   "I Am Lost at C"
   Examples We've Already Seen
   Moving Stacks to a C Extension Module
   Moving Stacks to a C Extension Type
   Now, Forget Most of the Details

Chapter 15. Embedding Python
   "Add Python. Mix well. Repeat."
   Python's Embedded Call API
   Basic Embedding Strategies
   A Higher-Level Embedded Call API
   An Embedded Call API Client
   Case Study: Embedding User-Coded Validations
   Other Approaches: Registering Callable Objects
   Other Integration Topics
   Automated Integration Techniques
   Summary: Python/C Integration Techniques

Chapter 16. Processing Language and Text
   "See Jack Hack. Hack, Jack, Hack"
   Strategies for Parsing Text in Python
   Case Study: A Calculator GUI
   The "Big Finish": A Real Calculator GUI
   Conclusion: Python and the Development Cycle" 697
   "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...
   "Roll the Closing Credits"

PART 4: Appendixes

Appendix A. ...And Other Cool Stuff

Appendix B. Futurisms

Appendix C. A Mini-Reference

Appendix D. An Application Framework

Appendix E. A Python Tutorial

Appendix F. Python Classes for C++ Programmers

Glossary

Glossary

Index

Return to Programming Python