Dedication;Preface; This Book''s "Ecosystem"; About This Fifth Edition; The Python 2.X and 3.X Lines; This Book''s Prerequisites and Effort; This Book''s Structure; What This Book Is Not; This Book''s Programs; Font Conventions; Book Updates and Resources; Acknowledgments;Getting Started; Chapter 1: A Python Q&A Session; 1.1 Why Do People Use Python?; 1.2 Is Python a "Scripting Language"?; 1.3 OK, but What''s the Downside?; 1.4 Who Uses Python Today?; 1.5 What Can I Do with Python?; 1.
6 How Is Python Developed and Supported?; 1.7 What Are Python''s Technical Strengths?; 1.8 How Does Python Stack Up to Language X?; 1.9 Chapter Summary; 1.10 Test Your Knowledge: Quiz; 1.11 Test Your Knowledge: Answers; Chapter 2: How Python Runs Programs; 2.1 Introducing the Python Interpreter; 2.2 Program Execution; 2.
3 Execution Model Variations; 2.4 Chapter Summary; 2.5 Test Your Knowledge: Quiz; 2.6 Test Your Knowledge: Answers; Chapter 3: How You Run Programs; 3.1 The Interactive Prompt; 3.2 System Command Lines and Files; 3.3 Unix-Style Executable Scripts: #!; 3.4 Clicking File Icons; 3.
5 Module Imports and Reloads; 3.6 Using exec to Run Module Files; 3.7 The IDLE User Interface; 3.8 Other IDEs; 3.9 Other Launch Options; 3.10 Which Option Should I Use?; 3.11 Chapter Summary; 3.12 Test Your Knowledge: Quiz; 3.
13 Test Your Knowledge: Answers; 3.14 Test Your Knowledge: Part I Exercises;Types and Operations; Chapter 4: Introducing Python Object Types; 4.1 The Python Conceptual Hierarchy; 4.2 Why Use Built-in Types?; 4.3 Python''s Core Data Types; 4.4 Numbers; 4.5 Strings; 4.6 Lists; 4.
7 Dictionaries; 4.8 Tuples; 4.9 Files; 4.10 Other Core Types; 4.11 Chapter Summary; 4.12 Test Your Knowledge: Quiz; 4.13 Test Your Knowledge: Answers; Chapter 5: Numeric Types; 5.1 Numeric Type Basics; 5.
2 Numbers in Action; 5.3 Other Numeric Types; 5.4 Numeric Extensions; 5.5 Chapter Summary; 5.6 Test Your Knowledge: Quiz; 5.7 Test Your Knowledge: Answers; Chapter 6: The Dynamic Typing Interlude; 6.1 The Case of the Missing Declaration Statements; 6.2 Shared References; 6.
3 Dynamic Typing Is Everywhere; 6.4 Chapter Summary; 6.5 Test Your Knowledge: Quiz; 6.6 Test Your Knowledge: Answers; Chapter 7: String Fundamentals; 7.1 This Chapter''s Scope; 7.2 String Basics; 7.3 String Literals; 7.4 Strings in Action; 7.
5 String Methods; 7.6 String Formatting Expressions; 7.7 String Formatting Method Calls; 7.8 General Type Categories; 7.9 Chapter Summary; 7.10 Test Your Knowledge: Quiz; 7.11 Test Your Knowledge: Answers; Chapter 8: Lists and Dictionaries; 8.1 Lists; 8.
2 Lists in Action; 8.3 Dictionaries; 8.4 Dictionaries in Action; 8.5 Chapter Summary; 8.6 Test Your Knowledge: Quiz; 8.7 Test Your Knowledge: Answers; Chapter 9: Tuples, Files, and Everything Else; 9.1 Tuples; 9.2 Files; 9.
3 Core Types Review and Summary; 9.4 Built-in Type Gotchas; 9.5 Chapter Summary; 9.6 Test Your Knowledge: Quiz; 9.7 Test Your Knowledge: Answers; 9.8 Test Your Knowledge: Part II Exercises;Statements and Syntax; Chapter 10: Introducing Python Statements; 10.1 The Python Conceptual Hierarchy Revisited; 10.2 Python''s Statements; 10.
3 A Tale of Two ifs; 10.4 A Quick Example: Interactive Loops; 10.5 Chapter Summary; 10.6 Test Your Knowledge: Quiz; 10.7 Test Your Knowledge: Answers; Chapter 11: Assignments, Expressions, and Prints; 11.1 Assignment Statements; 11.2 Expression Statements; 11.3 Print Operations; 11.
4 Chapter Summary; 11.5 Test Your Knowledge: Quiz; 11.6 Test Your Knowledge: Answers; Chapter 12: if Tests and Syntax Rules; 12.1 if Statements; 12.2 Python Syntax Revisited; 12.3 Truth Values and Boolean Tests; 12.4 The if/else Ternary Expression; 12.5 Chapter Summary; 12.
6 Test Your Knowledge: Quiz; 12.7 Test Your Knowledge: Answers; Chapter 13: while and for Loops; 13.1 while Loops; 13.2 break, continue, pass, and the Loop else; 13.3 for Loops; 13.4 Loop Coding Techniques; 13.5 Chapter Summary; 13.6 Test Your Knowledge: Quiz; 13.
7 Test Your Knowledge: Answers; Chapter 14: Iterations and Comprehensions; 14.1 Iterations: A First Look; 14.2 List Comprehensions: A First Detailed Look; 14.3 Other Iteration Contexts; 14.4 New Iterables in Python 3.X; 14.5 Other Iteration Topics; 14.6 Chapter Summary; 14.
7 Test Your Knowledge: Quiz; 14.8 Test Your Knowledge: Answers; Chapter 15: The Documentation Interlude; 15.1 Python Documentation Sources; 15.2 Common Coding Gotchas; 15.3 Chapter Summary; 15.4 Test Your Knowledge: Quiz; 15.5 Test Your Knowledge: Answers; 15.6 Test Your Knowledge: Part III Exercises;Functions and Generators; Chapter 16: Function Basics; 16.
1 Why Use Functions?; 16.2 Coding Functions; 16.3 A First Example: Definitions and Calls; 16.4 A Second Example: Intersecting Sequences; 16.5 Chapter Summary; 16.6 Test Your Knowledge: Quiz; 16.7 Test Your Knowledge: Answers; Chapter 17: Scopes; 17.1 Python Scope Basics; 17.
2 The global Statement; 17.3 Scopes and Nested Functions; 17.4 The nonlocal Statement in 3.X; 17.5 Why nonlocal? State Retention Options; 17.6 Chapter Summary; 17.7 Test Your Knowledge: Quiz; 17.8 Test Your Knowledge: Answers; Chapter 18: Arguments; 18.
1 Argument-Passing Basics; 18.2 Special Argument-Matching Modes; 18.3 The min Wakeup Call!; 18.4 Generalized Set Functions; 18.5 Emulating the Python 3.X print Function; 18.6 Chapter Summary; 18.7 Test Your Knowledge: Quiz; 18.
8 Test Your Knowledge: Answers; Chapter 19: Advanced Function Topics; 19.1 Function Design Concepts; 19.2 Recursive Functions; 19.3 Function Objects: Attributes and Annotations; 19.4 Anonymous Functions: lambda; 19.5 Functional Programming Tools; 19.6 Chapter Summary; 19.7 Test Your Knowledge: Quiz; 19.
8 Test Your Knowledge: Answers; Chapter 20: Comprehensions and Generations; 20.1 List Comprehensions and Functional Tools; 20.2 Generator Functions and Expressions; 20.3 Comprehension Syntax Summary; 20.4 Chapter Summary; 20.5 Test Your Knowledge: Quiz; 20.6 Test Your Knowledge: Answers; Chapter 21: The Benchmarking Interlude; 21.1 Timing Iteration Alternatives; 21.
2 Timing Iterations and Pythons with timeit; 21.3 Other Benchmarking Topics: pystones; 21.4 Function Gotchas; 21.5 Chapter Summary; 21.6 Test Your Knowledge: Quiz; 21.7 Test Your Knowledge: Answers; 21.8 Test Your Knowledge: Part IV Exercises;Modules and Packages; Chapter 22: Modules: The Big Picture; 22.1 Why Use Modules?; 22.
2 Python Program Architecture; 22.3 How Imports Work; 22.4 Byte Code Files: __pycache__ in Python 3.2+; 22.5 The Module Search Path; 22.6 Chapter Summary; 22.7 Test Your Knowledge: Quiz; 22.8 Test Your Knowledge: Answers; Chapter 23: Module Coding Basics; 23.
1 Module Creation; 23.2 Module Usage; 23.3 Module Namespaces; 23.4 Reloading Modules; 23.5 Chapter Summary; 23.6 Test Your Knowledge: Quiz; 23.7 Test Your Knowledge: Answers; Chapter 24: Module Packages; 24.1 Package Import Basics; 24.
2 Package Import Example; 24.3 Why Use Package Imports?; 24.4 Package Relative Imports; 24.5 Python 3.3 Namespace Packages; 24.6 Chapter Summary; 24.7 Test Your Knowledge: Quiz; 24.8 Test Your Knowledge: Answers; Chapter 25: Advanced Module Topics; 25.
1 Module Design Concepts; 25.2 Data Hiding in Modules; 25.3 Enabling Future Language Features: __future__; 25.4 Mixed Usage Modes: __name__ and __main__; 25.5 Example: Dual Mode Code; 25.6 Changing the Module Search Path; 25.7 The as Extension for import and from; 25.8 Example: Modules Are Objects; 25.
9 Importing Modules by Name String; 25.10 Example: Transitive Module Reloads; 25.11 Module Gotchas; 25.12 Chapter Summary; 25.13 Test Your Knowledge: Quiz; 25.14 Test Your Knowledge: Answers; 25.15 Test Your Knowledge: Part V Exercises;Classes and OOP; Chapter 26: OOP: The Big Picture; 26.1 Why Use Classes?; 26.
2 OOP from 30,000 Feet; 26.3 Chapter Summary; 26.4 Test Your Knowledge: Quiz; 26.5 Test Your Knowledge: Answers; Chapter 27: Class Coding Basics; 27.1 Classes Generate Multiple Instance Objects; 27.2 Classes Are Customized by Inheritance; 27.3 Classes Can Intercept Python Operators; 27.4 The World''s Simplest Python Class; 27.
5 Chapter Summary; 27.6 Test Your Knowledge: Quiz; 27.7 Test Your Knowledge: Answers; Chapter 28: A More Realistic Example; 28.1 Step 1: Making Instances; 28.2 Step 2: Adding Behavior Methods; 28.3 Step 3: Operator Overloading; 28.4 Step 4: Customizing Behavior by Subclassing; 28.5 Step 5: Customizing Constructors, Too; 28.
6 Step 6: Using Introspection Tools; 28.7 Step 7 (Final): Storing Objects in a Database; 28.8 Future Directions; 28.9 Chapter Summary; 28.10 Test Your Knowledge: Quiz; 28.11 Test Your Knowledge: Answers; Chapter 29: Class Coding Details; 29.1 The class Statement; 29.2 Methods; 29.
3 Inheritance; 29.4 Namespaces: The Conclusion; 29.5 Documentation Strings Revisited; 29.6 Classes Versus Modules; 29.7 Chapter Summary; 29.8 Test Your Knowledge: Quiz; 29.9 Test Your Knowledge: Answers; Chapter 30: Operator Overloading; 30.1 The Basics; 30.
2 Indexing and Slicing: __getitem__ and __setitem__; 30.3 Index Iteration: __getitem__; 30.4 Iterable Objects: __iter__ and __next__; 30.5 Membership: __contains__, __iter__, and __getitem__; 30.6 Attribute Access: __getattr__ and __setattr__; 30.7 String Representation: __repr__ and __str__; 30.8 Right-Side and In-Place Uses: __radd__ and __iadd__; 30.9 Call Expressions: __call__; 30.
10 Comparisons: __lt__, __gt__, and Others; 30.11 Boolean Tests: __bool__ and __len__; 30.12 Object Destruction: __del__; 30.13 Chapter Summary; 30.14 Test Your Knowledge: Quiz; 30.15 Test Your Knowledge: Answers; Chapter 31: Designing with Classes; 31.1 Python and OOP; 31.2 OOP and Inheritance: "Is-a" Relationships; 31.
3 OOP and Composition: "Has-a" Relationships; 31.4 OOP and Delegation: "Wrapper" Proxy Objects; 31.5 Pseudoprivate Class Attributes; 31.6 Methods Are Objects: Bound or Unbound; 31.7 Classes Are Objects: Generic Object Factories; 31.8 Multiple Inheritance: "Mix-in" Classes; 31.9 Other Design-Related Topics; 31.10 Chapter Summary; 31.
11 Test Your Knowledge: Quiz; 31.12 Test Your Knowledge: Answers;.