Learning Python Mark Lutz Learning Python Powerful Object-Oriented Programming 6th Edition
9 7 8 1 0 9 8 1 7 1 3 0 8 5 7 9 9 9 ISBN: 978-1-098-17130-8 US $79.99 CAN $99.99 PY THON / PROGR AMMING Get a comprehensive, in-depth introduction to the core Python language with this hands-on book. Based on author Mark Lutz’s popular training course, this updated sixth edition will help you quickly write efficient, high-quality code with Python. It’s an ideal way to begin, whether you’re new to programming or a professional developer versed in other languages. Complete with quizzes, exercises, and helpful illustrations, this easy-to-follow self-paced tutorial gets you started with Python 3.12 and all other releases in use today. With a pragmatic focus on what you need to know, it also introduces some advanced language features that have become increasingly common in Python code. • Explore Python’s built-in object types such as strings, lists, dictionaries, and files • Create and process objects with Python statements, and learn Python’s syntax model • Use functions and functional programming to avoid redundancy and maximize reuse • Organize code into larger components with modules and packages • Code robust programs with Python’s exception handling and development tools • Apply object-oriented programming and classes to make code customizable • Survey advanced Python tools including decorators, descriptors, and metaclasses • Write idiomatic Python code that runs portably across a wide variety of platforms Learning Python Mark Lutz is the author of Python’s classic and foundational texts, a former trainer with two decades of experience teaching Python to newcomers, and one of the people responsible for the prominence that Python enjoys today. For more author background, see Mark’s books-and-software website at learning-python.com.
Mark Lutz Learning Python Powerful Object-Oriented Programming SIXTH EDITION
978-1-098-17130-8 [LSI] Learning Python by Mark Lutz Copyright © 2025 Mark Lutz. All rights reserved. Printed in the United States of America. Published by O’Reilly Media, Inc., 1005 Gravenstein Highway North, Sebastopol, CA 95472. O’Reilly books may be purchased for educational, business, or sales promotional use. Online editions are also avail‐ able for most titles (http://oreilly.com). For more information, contact our corporate/institutional sales department: 800-998-9938 or corporate@oreilly.com. Acquisitions Editor: Louise Corrigan Development Editor: Sara Hunter Production Editor: Kristen Brown Copyeditor: nSight, Inc. Proofreader: Piper Content Partners Indexer: nSight, Inc. Interior Designer: David Futato Cover Designer: Karen Montgomery Illustrator: Kate Dullea March 2025: Sixth Edition Revision History for the Sixth Edition 2025-02-25: First Release See http://oreilly.com/catalog/errata.csp?isbn=9781098171308 for release details. The O’Reilly logo is a registered trademark of O’Reilly Media, Inc. Learning Python, the cover image, and related trade dress are trademarks of O’Reilly Media, Inc. The views expressed in this work are those of the author and do not represent the publisher’s views. While the pub‐ lisher and the author have used good faith efforts to ensure that the information and instructions contained in this work are accurate, the publisher and the author disclaim all responsibility for errors or omissions, including without limitation responsibility for damages resulting from the use of or reliance on this work. Use of the informa‐ tion and instructions contained in this work is at your own risk. If any code samples or other technology this work contains or describes is subject to open source licenses or the intellectual property rights of others, it is your respon‐ sibility to ensure that your use thereof complies with such licenses and/or rights.
To Vera. You are my life.
(This page has no text content)
Table of Contents Preface. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxxi Part I. Getting Started 1. A Python Q&A Session. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 Why Do People Use Python? 3 Software Quality 4 Developer Productivity 5 Is Python a “Scripting Language”? 5 OK, but What’s the Downside? 6 Who Uses Python Today? 7 What Can I Do with Python? 8 Systems Programming 8 GUIs and UIs 8 Internet and Web Scripting 8 Component Integration 9 Database Access 9 Rapid Prototyping 9 Numeric and Scientific Programming 10 And More: AI, Games, Images, QA, Excel, Apps… 10 What Are Python’s Technical Strengths? 10 It’s Object-Oriented and Functional 11 It’s Free and Open 11 It’s Portable 11 It’s Powerful 12 It’s Mixable 13 It’s Relatively Easy to Use 13 It’s Relatively Easy to Learn 13 Chapter Summary 14 v
Test Your Knowledge: Quiz 14 Test Your Knowledge: Answers 14 2. How Python Runs Programs. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17 Introducing the Python Interpreter 17 Program Execution 18 The Programmer’s View 18 Python’s View 18 Execution-Model Variations 21 Python Implementation Alternatives 22 Standalone Executables 24 Future Possibilities 25 Chapter Summary 25 Test Your Knowledge: Quiz 25 Test Your Knowledge: Answers 26 3. How You Run Programs. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27 Installing Python 27 Interactive Code 28 Starting an Interactive REPL 28 Where to Run: Code Folders 29 What Not to Type: Prompts and Comments 30 Other Python REPLs 30 Running Code Interactively 31 Why the Interactive Prompt? 32 Program Files 34 A First Script 34 Running Files with Command Lines 35 Command-Line Usage Variations 36 Other Ways to Run Files 37 Clicking and Tapping File Icons 37 The IDLE Graphical User Interface 38 Other IDEs for Python 39 Smartphone Apps 39 WebAssembly for Browsers 40 Jupyter Notebooks for Science 40 Ahead-of-Time Compilers for Speed 40 Running Code in Code 41 Other Launch Options 45 Which Option Should I Use? 46 Chapter Summary 46 Test Your Knowledge: Quiz 46 Test Your Knowledge: Answers 47 Test Your Knowledge: Part I Exercises 48 vi | Table of Contents
Part II. Objects and Operations 4. Introducing Python Objects. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53 The Python Conceptual Hierarchy 53 Why Use Built-in Objects? 54 Python’s Core Object Types 55 Numbers 56 Strings 57 Sequence Operations 58 Immutability 59 Type-Specific Methods 60 Getting Help 62 Other Ways to Code Strings 63 Unicode Strings 64 Lists 65 Sequence Operations 65 Type-Specific Operations 65 Bounds Checking 66 Nesting 66 Comprehensions 67 Dictionaries 69 Mapping Operations 69 Nesting Revisited 70 Missing Keys: if Tests 71 Item Iteration: for Loops 73 Tuples 74 Why Tuples? 75 Files 75 Unicode and Byte Files 76 Other File-Like Tools 77 Other Object Types 77 Sets 77 Booleans and None 78 Types 78 Type Hinting 79 User-Defined Objects 80 And Everything Else 80 Chapter Summary 81 Test Your Knowledge: Quiz 81 Test Your Knowledge: Answers 81 5. Numbers and Expressions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83 Numeric Object Basics 83 Numeric Literals 84 Table of Contents | vii
Built-in Numeric Tools 85 Python Expression Operators 85 Mixed Operators: Precedence 87 Parentheses Group Subexpressions 88 Mixed Types Are Converted Up 88 Preview: Operator Overloading and Polymorphism 89 Numbers in Action 89 Variables and Basic Expressions 89 Numeric Display Formats 91 Comparison Operators 92 Division Operators 94 Integer Precision 96 Complex Numbers 96 Hex, Octal, and Binary 96 Bitwise Operations 98 Underscore Separators in Numbers 99 Other Built-in Numeric Tools 101 Other Numeric Objects 103 Decimal Objects 103 Fraction Objects 104 Set Objects 106 Boolean Objects 112 Numeric Extensions 113 Chapter Summary 113 Test Your Knowledge: Quiz 113 Test Your Knowledge: Answers 114 6. The Dynamic Typing Interlude. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 115 The Case of the Missing Declaration Statements 115 Variables, Objects, and References 116 Types Live with Objects, Not Variables 118 Objects Are Garbage-Collected 118 Shared References 120 Shared References and In-Place Changes 121 Shared References and Equality 123 Dynamic Typing Is Everywhere 124 Type Hinting: Optional, Unused, and Why? 125 Chapter Summary 126 Test Your Knowledge: Quiz 126 Test Your Knowledge: Answers 127 7. String Fundamentals. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 129 String Object Basics 129 String Literals 131 viii | Table of Contents
Single and Double Quotes Are the Same 131 Escape Sequences Are Special Characters 132 Raw Strings Suppress Escapes 136 Triple Quotes and Multiline Strings 137 Strings in Action 138 Basic Operations 138 Indexing and Slicing 140 String Conversion Tools 143 “Changing” Strings Part 1: Sequence Operations 145 String Methods 146 Method Call Syntax 146 All String Methods (Today) 147 “Changing” Strings, Part 2: String Methods 148 More String Methods: Parsing Text 150 Other Common String Methods 151 String Formatting: The Triathlon 151 String-Formatting Options 152 The String-Formatting Expression 153 The String-Formatting Method 157 The F-String Formatting Literal 162 And the Winner Is… 167 General Type Categories 168 Types Share Operation Sets by Categories 168 Mutable Types Can Be Changed in Place 169 Chapter Summary 170 Test Your Knowledge: Quiz 170 Test Your Knowledge: Answers 170 8. Lists and Dictionaries. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 173 Lists 173 Lists in Action 175 Basic List Operations 175 Indexing and Slicing 176 Changing Lists in Place 177 More List Methods 180 Iteration, Comprehensions, and Unpacking 182 Other List Operations 184 Dictionaries 184 Dictionaries in Action 186 Basic Dictionary Operations 187 Changing Dictionaries in Place 187 More Dictionary Methods 188 Other Dictionary Makers 189 Dictionary Comprehensions 191 Table of Contents | ix
Key Insertion Ordering 192 Dictionary “Union” Operator 193 Intermission: Books Database 194 Dictionary Usage Tips 196 Chapter Summary 203 Test Your Knowledge: Quiz 203 Test Your Knowledge: Answers 203 9. Tuples, Files, and Everything Else. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 207 Tuples 207 Tuples in Action 209 Why Lists and Tuples? 211 Records Revisited: Named Tuples 212 Files 213 Opening Files 214 Using Files 214 Files in Action 216 Text and Binary Files: The Short Story 217 Storing Objects with Conversions 218 Storing Objects with pickle 220 Storing Objects with JSON 221 Storing Objects with Other Tools 222 File Context Managers 223 Other File Tools 223 Core Types Review and Summary 224 Object Flexibility 225 References Versus Copies 226 Comparisons, Equality, and Truth 228 The Meaning of True and False in Python 231 Python’s Type Hierarchies 233 Type Objects 233 Other Types in Python 234 Built-in Type Gotchas 235 Assignment Creates References, Not Copies 235 Repetition Adds One Level Deep 236 Beware of Cyclic Data Structures 237 Immutable Types Can’t Be Changed in Place 237 Chapter Summary 237 Test Your Knowledge: Quiz 238 Test Your Knowledge: Answers 238 Test Your Knowledge: Part II Exercises 239 x | Table of Contents
Part III. Statements and Syntax 10. Introducing Python Statements. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 245 The Python Conceptual Hierarchy Revisited 245 Python’s Statements 246 A Tale of Two ifs 248 What Python Adds 248 What Python Removes 248 Why Indentation Syntax? 250 A Few Special Cases 252 A Quick Example: Interactive Loops 254 A Simple Interactive Loop 254 Doing Math on User Inputs 255 Handling Errors by Testing Inputs 256 Handling Errors with try Statements 257 Supporting Floating-Point Numbers 258 Nesting Code Three Levels Deep 259 Chapter Summary 259 Test Your Knowledge: Quiz 260 Test Your Knowledge: Answers 260 11. Assignments, Expressions, and Prints. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 261 Assignments 261 Assignment Syntax Forms 262 Basic Assignments 263 Sequence Assignments 264 Extended-Unpacking Assignments 266 Multiple-Target Assignments 271 Augmented Assignments 272 Named Assignment Expressions 274 Variable Name Rules 277 Expression Statements 280 Expression Statements and In-Place Changes 281 Print Operations 282 The print Function 282 Print Stream Redirection 285 Chapter Summary 288 Test Your Knowledge: Quiz 288 Test Your Knowledge: Answers 288 12. if and match Selections. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 291 if Statements 291 General Format 291 Basic Examples 292 Table of Contents | xi
Multiple-Choice Selections 293 match Statements 295 Basic match Usage 295 Advanced match Usage 297 Python Syntax Revisited 299 Block Delimiters: Indentation Rules 300 Statement Delimiters: Lines and Continuations 302 Special Syntax Cases in Action 303 Truth Values Revisited 304 The if/else Ternary Expression 306 Chapter Summary 307 Test Your Knowledge: Quiz 307 Test Your Knowledge: Answers 308 13. while and for Loops. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 311 while Loops 311 General Format 311 Examples 312 break, continue, pass, and the Loop else 313 General Loop Format 313 pass 313 continue 314 break 315 Loop else 316 for Loops 318 General Format 318 Examples 318 Loop Coding Techniques 323 Counter Loops: range 324 Sequence Scans: while, range, and for 325 Sequence Shufflers: range and len 326 Skipping Items: range and Slices 327 Changing Lists: range and Comprehensions 327 Parallel Traversals: zip 328 Offsets and Items: enumerate 331 Chapter Summary 332 Test Your Knowledge: Quiz 332 Test Your Knowledge: Answers 332 14. Iterations and Comprehensions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 335 Iterations 336 The Iteration Protocol 337 Other Built-in Iterables 342 Comprehensions 347 xii | Table of Contents
List Comprehension Basics 347 List Comprehensions and Files 348 Extended List Comprehension Syntax 349 Comprehensions Cliff-Hanger 351 Iteration Tools 351 Other Iteration Topics 355 Chapter Summary 355 Test Your Knowledge: Quiz 356 Test Your Knowledge: Answers 356 15. The Documentation Interlude. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 357 Python Documentation Sources 357 # Comments 358 The dir Function 358 Docstrings and __doc__ 360 Pydoc: The help Function 363 Pydoc: HTML Reports 366 Beyond Docstrings: Sphinx 370 The Standard Manuals 370 Web Resources 371 Common Coding Gotchas 372 Chapter Summary 373 Test Your Knowledge: Quiz 373 Test Your Knowledge: Answers 374 Test Your Knowledge: Part III Exercises 374 Part IV. Functions and Generators 16. Function Basics. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 379 Why Use Functions? 380 Function Coding Overview 381 Basic Function Tools 381 Advanced Function Tools 382 General Function Concepts 382 def Statements 383 return Statements 383 def Executes at Runtime 384 lambda Makes Anonymous Functions 384 A First Example: Definitions and Calls 385 Definition 385 Calls 386 Polymorphism in Python 386 A Second Example: Intersecting Sequences 387 Table of Contents | xiii
Definition 387 Calls 388 Polymorphism Revisited 389 Segue: Local Variables 389 Chapter Summary 390 Test Your Knowledge: Quiz 390 Test Your Knowledge: Answers 390 17. Scopes. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 393 Python Scopes Basics 393 Scopes Overview 394 Name Resolution: The LEGB Rule 396 Scopes Examples 398 The Built-in Scope 399 The global Statement 401 Program Design: Minimize Global Variables 402 Program Design: Minimize Cross-File Changes 404 Other Ways to Access Globals 405 Nested Functions and Scopes 406 Nested Scopes Overview 406 Nested Scopes Examples 406 Closures and Factory Functions 407 Arbitrary Scope Nesting 409 The nonlocal Statement 409 nonlocal Basics 410 nonlocal in Action 410 nonlocal Boundary Cases 411 State-Retention Options 412 Nonlocals: Changeable, Per-Call, LEGB 413 Globals: Changeable but Shared 413 Function Attributes: Changeable, Per-Call, Explicit 414 Classes: Changeable, Per-Call, OOP 416 And the Winner Is… 416 Scopes and Argument Defaults 416 Loops Require Defaults, Not Scopes 418 Chapter Summary 419 Test Your Knowledge: Quiz 420 Test Your Knowledge: Answers 421 18. Arguments. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 423 Argument-Passing Basics 423 Arguments and Shared References 424 Avoiding Mutable Argument Changes 426 Simulating Output Parameters and Multiple Results 427 xiv | Table of Contents
Special Argument-Matching Modes 428 Argument Matching Overview 428 Argument Matching Syntax 429 Argument Passing Details 430 Keyword and Default Examples 431 Arbitrary Arguments Examples 433 Keyword-Only Arguments 437 Positional-Only Arguments 439 Argument Ordering: The Gritty Details 440 Definition Ordering 440 Calls Ordering 442 Example: The min Wakeup Call 443 Full Credit 443 Bonus Points 445 The Punch Line 446 Example: Generalized Set Functions 446 Testing the Code 447 Example: Rolling Your Own Print 448 Using Keyword-Only Arguments 449 Chapter Summary 451 Test Your Knowledge: Quiz 451 Test Your Knowledge: Answers 452 19. Function Odds and Ends. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 455 Function Design Concepts 455 Recursive Functions 457 Summation with Recursion 457 Coding Alternatives 458 Loop Statements Versus Recursion 459 Handling Arbitrary Structures 460 Function Tools: Attributes, Annotations, Etc. 464 The First-Class Object Model 465 Function Introspection 466 Function Attributes 467 Function Annotations and Decorations 468 Anonymous Functions: lambda 470 lambda Basics 471 Why Use lambda? 472 How (Not) to Obfuscate Your Python Code 473 Scopes: lambdas Can Be Nested Too 475 Functional Programming Tools 475 Mapping Functions over Iterables: map 476 Selecting Items in Iterables: filter 477 Combining Items in Iterables: reduce 478 Table of Contents | xv
Chapter Summary 479 Test Your Knowledge: Quiz 479 Test Your Knowledge: Answers 479 20. Comprehensions and Generations. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 483 Comprehensions: The Final Act 483 List Comprehensions Review 484 Formal Comprehension Syntax 485 Example: List Comprehensions and Matrixes 487 Generator Functions and Expressions 490 Generator Functions: yield Versus return 490 Generator Expressions: Iterables Meet Comprehensions 496 Generator Functions Versus Generator Expressions 500 Generator Odds and Ends 501 Example: Shuffling Sequences 506 Scrambling Sequences 506 Permutating Sequences 509 Example: Emulating zip and map 513 Coding Your Own map 514 Coding Your Own zip and 2.X map 515 Asynchronous Functions: The Short Story 517 Async Basics 518 The Async Wrap-Up 524 Chapter Summary 525 Test Your Knowledge: Quiz 525 Test Your Knowledge: Answers 525 21. The Benchmarking Interlude. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 529 Benchmarking with Homegrown Tools 529 Timer Module: Take 1 530 Timer Module: Take 2 531 Timing Runner and Script 533 Iteration Results 535 More Module Mods 538 Benchmarking with Python’s timeit 540 Basic timeit Usage 540 Automating timeit Benchmarking 544 Function Gotchas 549 Local Names Are Detected Statically 549 Defaults and Mutable Objects 550 Functions Without returns 552 Miscellaneous Function Gotchas 552 Chapter Summary 553 Test Your Knowledge: Quiz 553 xvi | Table of Contents
Test Your Knowledge: Answers 553 Test Your Knowledge: Part IV Exercises 554 Part V. Modules and Packages 22. Modules: The Big Picture. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 559 Module Essentials 559 Why Use Modules? 560 Python Program Architecture 560 How to Structure a Program 561 Imports and Attributes 561 Standard-Library Modules 563 How Imports Work 563 Step 1: Find It 564 Step 2: Compile It (Maybe) 564 Step 3: Run It 567 The Module Search Path 567 Search-Path Components 567 Configuring the Search Path 570 The sys.path List 570 Module File Selection 571 Path Outliers: Standalones and Packages 572 Chapter Summary 573 Test Your Knowledge: Quiz 573 Test Your Knowledge: Answers 573 23. Module Coding Basics. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 575 Creating Modules 575 Module Filenames 575 Other Kinds of Modules 576 Using Modules 576 The import Statement 576 The from Statement 577 The from * Statement 577 Imports Happen Only Once 578 Imports Are Runtime Assignments 579 import and from Equivalence 580 Potential Pitfalls of the from Statement 580 Module Namespaces 582 How Files Generate Namespaces 582 Namespace Dictionaries: __dict__ 583 Attribute Name Qualification 584 Imports Versus Scopes 585 Table of Contents | xvii
Namespace Nesting 586 Reloading Modules 587 reload Basics 588 reload Example 588 reload Odds and Ends 590 Chapter Summary 590 Test Your Knowledge: Quiz 590 Test Your Knowledge: Answers 591 24. Module Packages. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 593 Using Packages 593 Package Imports 594 Packages and the Module Search Path 594 Creating Packages 595 Basic Package Structure 595 Package __init__.py Files 597 Package __main__.py Files 599 Why Packages? 600 A Tale of Two Systems 600 The Roles of __init__.py Files 603 Package-Relative Imports 604 Relative and Absolute Imports 604 Relative-Import Rationales and Trade-Offs 605 Package-Relative Imports in Action 605 Namespace Packages 609 Python Import Models 609 Namespace-Package Rationales 610 The Module Search Algorithm 610 Namespace Packages in Action 611 Chapter Summary 613 Test Your Knowledge: Quiz 614 Test Your Knowledge: Answers 614 25. Module Odds and Ends. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 617 Module Design Concepts 617 Data Hiding in Modules 618 Minimizing from * Damage: _X and __all__ 619 Managing Attribute Access: __getattr__ and __dir__ 620 Enabling Language Changes: __future__ 622 Dual-Usage Modes: __name__ and __main__ 622 Example: Unit Tests with __name__ 623 The as Extension for import and from 625 Module Introspection 626 Example: Listing Modules with __dict__ 627 xviii | Table of Contents
Comments 0
Loading comments...
Reply to Comment
Edit Comment