Learning Python, Third Edition
By
Mark Lutz
October 2007
Pages: 746
| Table of Contents
| Index
| Sample Chapter
| Colophon
Table of Contents
-
Getting Started
-
Chapter 1 A Python Q&A Session
- Why Do People Use Python?
- Is Python a "Scripting Language"?
- OK, 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 Summary
-
Chapter 2 How Python Runs Programs
- Introducing the Python Interpreter
- Program Execution
- Execution Model Variations
- Chapter Summary
-
Chapter 3 How You Run Programs
- Interactive Coding
- System Command Lines and Files
- Clicking 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?
- Chapter Summary
- BRAIN BUILDER
-
Types and Operations
-
Chapter 4 Introducing Python Object Types
- Why Use Built-in Types?
- Numbers
- Strings
- Lists
- Dictionaries
- Tuples
- Files
- Other Core Types
- Chapter Summary
-
Chapter 5 Numbers
- Python Numeric Types
- Python Expression Operators
- Numbers in Action
- Other Numeric Types
- Chapter Summary
-
Chapter 6 The Dynamic Typing Interlude
- The Case of the Missing Declaration Statements
- Shared References
- Dynamic Typing Is Everywhere
- Chapter Summary
-
Chapter 7 ofsmallStrings
- String Literals
- Strings in Action
- String Formatting
- String Methods
- General Type Categories
- Chapter Summary
-
Chapter 8 Lists and Dictionaries
- Lists
- Lists in Action
- Dictionaries
- Dictionaries in Action
- Chapter Summary
-
Chapter 9 Tuples, Files, and Everything Else
- Tuples
- Files
- Type Categories Revisited
- Object Flexibility
- References Versus Copies
- Comparisons, Equality, and Truth
- Python's Type Hierarchies
- Other Types in Python
- Built-in Type Gotchas
- Chapter Summary
- BRAIN BUILDER
-
Statements and Syntax
-
Chapter 10 Introducing Python Statements
- Python Program Structure Revisited
- A Tale of Two ifs
- A Quick Example: Interactive Loops
- Chapter Summary
-
Chapter 11 rwordsAssignment, Expressions, and print
- Assignment Statements
- Expression Statements
- print Statements
- Chapter Summary
-
Chapter 12 if Tests
- if Statements
- Python Syntax Rules
- Truth Tests
- Chapter Summary
-
Chapter 13 while and for Loops
- while Loops
- break, continue, pass, and the Loop else
- for Loops
- Iterators: A First Look
- Loop Coding Techniques
- List Comprehensions: A First Look
- Chapter Summary
-
Chapter 14 The Documentation Interlude
- Python Documentation Sources
- Common Coding Gotchas
- Chapter Summary
- BRAIN BUILDER
-
Functions
-
Chapter 15 Function Basics
- Why Use Functions?
- A First Example: Definitions and Calls
- A Second Example: Intersecting Sequences
- Chapter Summary
-
Chapter 16 Scopes and Arguments
- Scope Rules
- The global Statement
- Scopes and Nested Functions
- Passing Arguments
- Special Argument-Matching Modes
- Chapter Summary
-
Chapter 17 Advanced Function Topics
- Anonymous Functions: lambda
- Applying Functions to Arguments
- Mapping Functions over Sequences: map
- Functional Programming Tools: filter and reduce
- List Comprehensions Revisited: Mappings
- Iterators Revisited: Generators
- Timing Iteration Alternatives
- Function Design Concepts
- Function Gotchas
- Chapter Summary
- BRAIN BUILDER
-
Modules
-
Chapter 18 Modules: The Big Picture
- Why Use Modules?
- Python Program Architecture
- How Imports Work
- Chapter Summary
-
Chapter 19 Module Coding Basics
- Module Creation
- Module Usage
- Module Namespaces
- Reloading Modules
- Chapter Summary
-
Chapter 20 Module Packages
- Package Import Basics
- Package Import Example
- Why Use Package Imports?
- Chapter Summary
-
Chapter 21 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
- Relative Import Syntax
- Module Design Concepts
- Module Gotchas
- Chapter Summary
- BRAIN BUILDER
-
Classes and OOP
-
Chapter 22 OOP: The Big Picture
- Why Use Classes?
- OOP from 30,000 Feet
- Chapter Summary
-
Chapter 23 Class Coding Basics
- Classes Generate Multiple Instance Objects
- Classes Are Customized by Inheritance
- Classes Can Intercept Python Operators
- The World's Simplest Python Class
- Chapter Summary
-
Chapter 24 Class Coding Details
- The class Statement
- Methods
- Inheritance
- Operator Overloading
- Namespaces: The Whole Story
- A More Realistic Example
- Chapter Summary
-
Chapter 25 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 Summary
-
Chapter 26 Advanced Class Topics
- Extending Built-in Types
- Pseudoprivate Class Attributes
- New-Style Classes
- Static and Class Methods
- Function Decorators
- Class Gotchas
- Chapter Summary
- BRAIN BUILDER
-
Exceptions and Tools
-
Chapter 27 Exception Basics
- Why Use Exceptions?
- Exception Handling: The Short Story
- The try/except/else Statement
- The try/finally Statement
- Unified try/except/finally
- The raise Statement
- The assert Statement
- with/as Context Managers
- Chapter Summary
-
Chapter 28 Exception Objects
- String-Based Exceptions
- Class-Based Exceptions
- General raise Statement Forms
- Chapter Summary
-
Chapter 29 Designing with Exceptions
- Nesting Exception Handlers
- Exception Idioms
- Exception Design Tips
- Exception Gotchas
- Core Language Summary
- Chapter Summary
- BRAIN BUILDER
-
Appendixes
-
Appendix Installation and Configuration
- Installing the Python Interpreter
- Configuring Python
-
Appendix Solutions to End-of-Part 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
-
Colophon
Return to Learning Python