Please consider the latest edition.
-
Getting Started
-
Chapter 1 A Python Q&A Session
- Why Do People Use Python?
- Is Python a Scripting Language?
- Okay, But What's the Downside?
- Who Uses Python Today?
- What Can I Do with Python?
- What Are Python's Technical Strengths?
- How Does Python Stack Up to Language X?
-
Chapter 2 How Python Runs Programs
- Introducing the Python Interpreter
- Program Execution
- Execution Model Variations
-
Chapter 3 How You Run Programs
- Interactive Coding
- System Command Lines and Files
- Clicking Windows File Icons
- Module Imports and Reloads
- The IDLE User Interface
- Other IDEs
- Embedding Calls
- Frozen Binary Executables
- Text Editor Launch Options
- Other Launch Options
- Future Possibilities?
- Which Option Should I Use?
- Part I Exercises
-
-
Types and Operations
-
Chapter 4 Numbers
- Python Program Structure
- Why Use Built-in Types?
- Numbers
- Python Expression Operators
- Numbers in Action
- The Dynamic Typing Interlude
-
Chapter 5 Strings
- String Literals
- Strings in Action
- String Formatting
- String Methods
- General Type Categories
-
Chapter 6 Lists and Dictionaries
- Lists
- Lists in Action
- Dictionaries
- Dictionaries in Action
-
Chapter 7 Tuples, Files, and Everything Else
- Tuples
- Files
- Type Categories Revisited
- Object Generality
- References Versus Copies
- Comparisons, Equality, and Truth
- Python's Type Hierarchies
- Other Types in Python
- Built-in Type Gotchas
- Part II Exercises
-
-
Statements and Syntax
-
Chapter 8 Assignment, Expressions, and Print
- Assignment Statements
- Expression Statements
- Print Statements
-
Chapter 9 if Tests
- if Statements
- Python Syntax Rules
- Truth Tests
-
Chapter 10 while and for Loops
- while Loops
- break, continue, pass, and the Loop else
- for Loops
- Loop Variations
-
Chapter 11 Documenting Python Code
- The Python Documentation Interlude
- Common Coding Gotchas
- Part III Exercises
-
-
Functions
-
Chapter 12 Function Basics
- Why Use Functions?
- Coding Functions
- A First Example: Definitions and Calls
- A Second Example: Intersecting Sequences
-
Chapter 13 Scopes and Arguments
- Scope Rules
- The global Statement
- Scopes and Nested Functions
- Passing Arguments
- Special Argument Matching Modes
-
Chapter 14 Advanced Function Topics
- Anonymous Functions: lambda
- Applying Functions to Arguments
- Mapping Functions Over Sequences
- Functional Programming Tools
- List Comprehensions
- Generators and Iterators
- Function Design Concepts
- Function Gotchas
- Part IV Exercises
-
-
Modules
-
Chapter 15 Modules: The Big Picture
- Why Use Modules?
- Python Program Architecture
- How Imports Work
-
Chapter 16 Module Coding Basics
- Module Creation
- Module Usage
- Module Namespaces
- Reloading Modules
-
Chapter 17 Module Packages
- Package Import Basics
- Package Import Example
- Why Use Package Imports?
- A Tale of Three Systems
-
Chapter 18 Advanced Module Topics
- Data Hiding in Modules
- Enabling Future Language Features
- Mixed Usage Modes: __name__ and __main__
- Changing the Module Search Path
- The import as Extension
- Module Design Concepts
- Module Gotchas
- Part V Exercises
-
-
Classes and OOP
-
Chapter 19 OOP: The Big Picture
- Why Use Classes?
- OOP from 30,000 Feet
-
Chapter 20 Class Coding Basics
- Classes Generate Multiple Instance Objects
- Classes Are Customized by Inheritance
- Classes Can Intercept Python Operators
-
Chapter 21 Class Coding Details
- The Class Statement
- Methods
- Inheritance
- Operator Overloading
- Namespaces: The Whole Story
-
Chapter 22 Designing with Classes
- Python and OOP
- Classes as Records
- OOP and Inheritance: "is-a" Relationships
- OOP and Composition: "has-a" Relationships
- OOP and Delegation
- Multiple Inheritance
- Classes Are Objects: Generic Object Factories
- Methods Are Objects: Bound or Unbound
- Documentation Strings Revisited
- Classes Versus Modules
-
Chapter 23 Advanced Class Topics
- Extending Built-in Types
- Pseudo-Private Class Attributes
- "New Style" Classes in Python 2.2
- Class Gotchas
- Part VI Exercises
-
-
Exceptions and Tools
-
Chapter 24 Exception Basics
- Why Use Exceptions?
- Exception Handling: The Short Story
- The try/except/else Statement
- The try/finally Statement
- The raise Statement
- The assert Statement
-
Chapter 25 Exception Objects
- String-Based Exceptions
- Class-Based Exceptions
- General raise Statement Forms
-
Chapter 26 Designing with Exceptions
- Nesting Exception Handlers
- Exception Idioms
- Exception Design Tips
- Exception Gotchas
- Core Language Summary
- Part VII Exercises
-
-
The Outer Layers
-
Chapter 27 Common Tasks in Python
- Exploring on Your Own
- Conversions, Numbers, and Comparisons
- Manipulating Strings
- Data Structure Manipulations
- Manipulating Files and Directories
- Internet-Related Modules
- Executing Programs
- Debugging, Testing, Timing, Profiling
- Exercises
-
Chapter 28 Frameworks
- An Automated Complaint System
- Interfacing with COM: Cheap Public Relations
- A Tkinter-Based GUI Editor for Managing Form Data
- Jython: The Felicitous Union of Python and Java
- Exercises
-
Chapter 29 Python Resources
- Layers of Community
- The Process
- Services and Products
- The Legal Framework: The Python Software Foundation
- Software
- Popular Third-Party Software
- Web Application Frameworks
- Tools for Python Developers
-
-
Appendixes
-
Appendix A Installation and Configuration
- Installing the Python Interpreter
-
Appendix B Solutions to Exercises
- Part I, Getting Started
- Part II, Types and Operations
- Part III, Statements and Syntax
- Part IV, Functions
- Part V, Modules
- Part VI, Classes and OOP
- Part VII, Exceptions and Tools
- Part VIII, The Outer Layers
-
-
Colophon
- Title:
- Learning Python, Second Edition
- By:
- Mark Lutz, David Ascher
- Publisher:
- O'Reilly Media
- Formats:
-
- Ebook
- Safari Books Online
- Print Release:
- December 2003
- Ebook Release:
- February 2009
- Pages:
- 624
- Print ISBN:
- 978-0-596-00281-7
- | ISBN 10:
- 0-596-00281-5
- Ebook ISBN:
- 978-0-596-10337-8
- | ISBN 10:
- 0-596-10337-9
Our look is the result of reader comments, our own experimentation, and feedback from distribution channels. Distinctive covers complement our distinctive approach to technical topics, breathing personality and life into potentially dry subjects. The animal on the cover of Learning Python, Second Edition is a wood rat (Neotoma, family Muridae). The wood rat lives in a wide range of living conditions (mostly rocky, scrub, and desert areas) over much of North and Central America, generally at some distance from humans, though they occasionally damage some crops. They are good climbers, nesting in trees or bushes up to six meters off the ground; some species burrow underground or in rock crevices or inhabit other species' abandoned holes.
These grayish-beige, medium-sized rodents are the original pack rats: they carry anythingand everything into their homes, whether or not it's needed, and are especially attracted to shiny objects such as tin cans, glass, and silverware. Matt Hutchinson was the production editor for Learning Python, Second Edition. Argosy Publishing provided production services. Colleen Gorman, Emily Quill, and Mary Anne Mayo provided quality control.
Edie Freedman designed the cover of this book. The cover image is a 19th-century engraving from Cuvier's Animals. Emma Colby produced the cover layout with QuarkXPress 4.1 using Adobe's ITC Garamond font.
David Futato designed the interior layout. This book was converted by Julie Hawks to FrameMaker 5.5.6 with a format conversion tool created by Erik Ray, Jason McIntosh, Neil Walls, and Mike Sierra that uses Perl and XML technologies. The text font is Linotype Birka; the headingfont is Adobe Myriad Condensed; and the code font is LucasFont's TheSans Mono Condensed. The illustrations that appear in the book were produced by Robert Romano and Jessamyn Read usingMacromedia FreeHand 9 and Adobe Photoshop 6. The tip and warningicons were drawn by Christopher Bing. This colophon was written by Nancy Kotary.
