Learning Python 5E Manual
User Manual:
Open the PDF directly: View PDF
Page Count: 1594 [warning: Documents this large are best viewed by clicking the View PDF Link!]
- Table of Contents
- Preface
- Part I. 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?
- How Is Python Developed and Supported?
- What Are Python’s Technical Strengths?
- How Does Python Stack Up to Language X?
- Chapter Summary
- Test Your Knowledge: Quiz
- Test Your Knowledge: Answers
- Chapter 2. How Python Runs Programs
- Chapter 3. How You Run Programs
- The Interactive Prompt
- System Command Lines and Files
- Unix-Style Executable Scripts: #!
- Clicking File Icons
- Module Imports and Reloads
- Using exec to Run Module Files
- The IDLE User Interface
- Other IDEs
- Other Launch Options
- Which Option Should I Use?
- Chapter Summary
- Test Your Knowledge: Quiz
- Test Your Knowledge: Answers
- Test Your Knowledge: Part I Exercises
- Chapter 1. A Python Q&A Session
- Part II. Types and Operations
- Chapter 4. Introducing Python Object Types
- Chapter 5. Numeric Types
- Numeric Type Basics
- Numbers in Action
- Other Numeric Types
- Numeric Extensions
- Chapter Summary
- Test Your Knowledge: Quiz
- Test Your Knowledge: Answers
- Chapter 6. The Dynamic Typing Interlude
- Chapter 7. String Fundamentals
- This Chapter’s Scope
- String Basics
- String Literals
- Strings in Action
- String Methods
- String Formatting Expressions
- String Formatting Method Calls
- Formatting Method Basics
- Adding Keys, Attributes, and Offsets
- Advanced Formatting Method Syntax
- Advanced Formatting Method Examples
- Comparison to the % Formatting Expression
- Why the Format Method?
- Extra features: Special-case “batteries” versus general techniques
- Flexible reference syntax: Extra complexity and functional overlap
- Explicit value references: Now optional and unlikely to be used
- Named method and context-neutral arguments: Aesthetics versus practice
- Functions versus expressions: A minor convenience
- General Type Categories
- Chapter Summary
- Test Your Knowledge: Quiz
- Test Your Knowledge: Answers
- Chapter 8. Lists and Dictionaries
- Lists
- Lists in Action
- Dictionaries
- Dictionaries in Action
- Chapter Summary
- Test Your Knowledge: Quiz
- Test Your Knowledge: Answers
- Chapter 9. Tuples, Files, and Everything Else
- Part III. Statements and Syntax
- Chapter 10. Introducing Python Statements
- Chapter 11. Assignments, Expressions, and Prints
- Assignment Statements
- Expression Statements
- Print Operations
- Chapter Summary
- Test Your Knowledge: Quiz
- Test Your Knowledge: Answers
- Chapter 12. if Tests and Syntax Rules
- Chapter 13. while and for Loops
- while Loops
- break, continue, pass, and the Loop else
- for Loops
- Loop Coding Techniques
- Chapter Summary
- Test Your Knowledge: Quiz
- Test Your Knowledge: Answers
- Chapter 14. Iterations and Comprehensions
- Chapter 15. The Documentation Interlude
- Python Documentation Sources
- Common Coding Gotchas
- Chapter Summary
- Test Your Knowledge: Quiz
- Test Your Knowledge: Answers
- Test Your Knowledge: Part III Exercises
- Part IV. Functions and Generators
- Chapter 16. Function Basics
- Chapter 17. Scopes
- Chapter 18. Arguments
- Argument-Passing Basics
- Special Argument-Matching Modes
- The min Wakeup Call!
- Generalized Set Functions
- Emulating the Python 3.X print Function
- Chapter Summary
- Test Your Knowledge: Quiz
- Test Your Knowledge: Answers
- Chapter 19. Advanced Function Topics
- Chapter 20. Comprehensions and Generations
- List Comprehensions and Functional Tools
- Generator Functions and Expressions
- Generator Functions: yield Versus return
- Generator Expressions: Iterables Meet Comprehensions
- Generator Functions Versus Generator Expressions
- Generators Are Single-Iteration Objects
- Generation in Built-in Types, Tools, and Classes
- Example: Generating Scrambled Sequences
- Don’t Abuse Generators: EIBTI
- Example: Emulating zip and map with Iteration Tools
- Comprehension Syntax Summary
- Chapter Summary
- Test Your Knowledge: Quiz
- Test Your Knowledge: Answers
- Chapter 21. The Benchmarking Interlude
- Timing Iteration Alternatives
- Timing Iterations and Pythons with timeit
- Other Benchmarking Topics: pystones
- Function Gotchas
- Chapter Summary
- Test Your Knowledge: Quiz
- Test Your Knowledge: Answers
- Test Your Knowledge: Part IV Exercises
- Part V. Modules and Packages
- Chapter 22. Modules: The Big Picture
- Chapter 23. Module Coding Basics
- Chapter 24. Module Packages
- Package Import Basics
- Package Import Example
- Why Use Package Imports?
- Package Relative Imports
- Python 3.3 Namespace Packages
- Chapter Summary
- Test Your Knowledge: Quiz
- Test Your Knowledge: Answers
- Chapter 25. Advanced Module Topics
- Module Design Concepts
- Data Hiding in Modules
- Enabling Future Language Features: __future__
- Mixed Usage Modes: __name__ and __main__
- Example: Dual Mode Code
- Changing the Module Search Path
- The as Extension for import and from
- Example: Modules Are Objects
- Importing Modules by Name String
- Example: Transitive Module Reloads
- Module Gotchas
- Chapter Summary
- Test Your Knowledge: Quiz
- Test Your Knowledge: Answers
- Test Your Knowledge: Part V Exercises
- Part VI. Classes and OOP
- Chapter 26. OOP: The Big Picture
- Chapter 27. Class Coding Basics
- Chapter 28. A More Realistic Example
- Step 1: Making Instances
- Step 2: Adding Behavior Methods
- Step 3: Operator Overloading
- Step 4: Customizing Behavior by Subclassing
- Step 5: Customizing Constructors, Too
- Step 6: Using Introspection Tools
- Step 7 (Final): Storing Objects in a Database
- Future Directions
- Chapter Summary
- Test Your Knowledge: Quiz
- Test Your Knowledge: Answers
- Chapter 29. Class Coding Details
- Chapter 30. Operator Overloading
- The Basics
- Indexing and Slicing: __getitem__ and __setitem__
- Index Iteration: __getitem__
- Iterable Objects: __iter__ and __next__
- Membership: __contains__, __iter__, and __getitem__
- Attribute Access: __getattr__ and __setattr__
- String Representation: __repr__ and __str__
- Right-Side and In-Place Uses: __radd__ and __iadd__
- Call Expressions: __call__
- Comparisons: __lt__, __gt__, and Others
- Boolean Tests: __bool__ and __len__
- Object Destruction: __del__
- Chapter Summary
- Test Your Knowledge: Quiz
- Test Your Knowledge: Answers
- Chapter 31. Designing with Classes
- Python and OOP
- OOP and Inheritance: “Is-a” Relationships
- OOP and Composition: “Has-a” Relationships
- OOP and Delegation: “Wrapper” Proxy Objects
- Pseudoprivate Class Attributes
- Methods Are Objects: Bound or Unbound
- Classes Are Objects: Generic Object Factories
- Multiple Inheritance: “Mix-in” Classes
- Other Design-Related Topics
- Chapter Summary
- Test Your Knowledge: Quiz
- Test Your Knowledge: Answers
- Chapter 32. Advanced Class Topics
- Extending Built-in Types
- The “New Style” Class Model
- New-Style Class Changes
- New-Style Class Extensions
- Static and Class Methods
- Decorators and Metaclasses: Part 1
- The super Built-in Function: For Better or Worse?
- Class Gotchas
- Chapter Summary
- Test Your Knowledge: Quiz
- Test Your Knowledge: Answers
- Test Your Knowledge: Part VI Exercises
- Part VII. Exceptions and Tools
- Chapter 33. Exception Basics
- Chapter 34. Exception Coding Details
- Chapter 35. Exception Objects
- Chapter 36. Designing with Exceptions
- Part VIII. Advanced Topics
- Chapter 37. Unicode and Byte Strings
- Chapter 38. Managed Attributes
- Chapter 39. Decorators
- What’s a Decorator?
- The Basics
- Coding Function Decorators
- Coding Class Decorators
- Managing Functions and Classes Directly
- Example: “Private” and “Public” Attributes
- Implementing Private Attributes
- Implementation Details I
- Generalizing for Public Declarations, Too
- Implementation Details II
- Open Issues
- Python Isn’t About Control
- Example: Validating Function Arguments
- Chapter Summary
- Test Your Knowledge: Quiz
- Test Your Knowledge: Answers
- Chapter 40. Metaclasses
- Chapter 41. All Good Things
- Part IX. Appendixes
- Appendix A. Installation and Configuration
- Appendix B. The Python 3.3 Windows Launcher
- Appendix C. Python Changes and This Book
- Appendix D. Solutions to End-of-Part Exercises
- Index