Item 3: Never Expect Python to Detect Errors at Compile Time
Item 4: Write Helper Functions Instead of Complex Expressions
Item 6: Always Surround Single-Element Tuples with Parentheses
Item 7: Consider Conditional Expressions for Simple Inline Logic
Item 9: Consider match for Destructuring in Flow Control; Avoid When if Statements Are Sufficient
Item 25: Be Cautious when Relying on Dictionary Insertion Ordering
Item 26: Prefer get over in and KeyError to Handle Missing Dictionary Keys
Item 27: Prefer defaultdict over setdefault to Handle Missing Items in Internal State
Item 28: Know How to Construct Key-Dependent Default Values with __missing__
Item 29: Compose Classes Instead of Deeply Nesting Dictionaries, Lists, and Tuples
Item 33: Know How Closures Interact with Variable Scope and nonlocal
Item 34: Reduce Visual Noise with Variable Positional Arguments
Item 36: Use None and Docstrings to Specify Dynamic Default Arguments
Item 37: Enforce Clarity with Keyword-Only and Positional-Only Arguments
Item 39: Prefer functools.partial over lambda Expressions for Glue Functions
Chapter 6 Comprehensions and Generators
Item 41: Avoid More Than Two Control Subexpressions in Comprehensions
Item 42: Reduce Repetition in Comprehensions with Assignment Expressions
Item 44: Consider Generator Expressions for Large List Comprehensions
Item 46: Pass Iterators into Generators as Arguments Instead of Calling the send Method
Item 47: Manage Iterative State Transitions with a Class Instead of the Generator throw Method
Chapter 7 Classes and Interfaces
Item 48: Accept Functions Instead of Classes for Simple Interfaces
Item 49: Prefer Object-Oriented Polymorphism over Functions with isinstance Checks
Item 51: Prefer dataclasses for Defining Lightweight Classes
Item 52: Use @classmethod Polymorphism to Construct Objects Generically
Item 54: Consider Composing Functionality with Mix-in Classes
Item 57: Inherit from collections.abc Classes for Custom Container Types
Chapter 8 Metaclasses and Attributes
Item 58: Use Plain Attributes Instead of Setter and Getter Methods
Item 59: Consider @property Instead of Refactoring Attributes
Item 61: Use __getattr__, __getattribute__, and __setattr__ for Lazy Attributes
Item 65: Consider Class Body Definition Order to Establish Relationships Between Attributes
Item 66: Prefer Class Decorators over Metaclasses for Composable Class Extensions
Chapter 9 Concurrency and Parallelism
Item 68: Use Threads for Blocking I/O; Avoid for Parallelism
Item 71: Know How to Recognize When Concurrency Is Necessary
Item 72: Avoid Creating New Thread Instances for On-Demand Fan-out
Item 73: Understand How Using Queue for Concurrency Requires Refactoring
Item 74: Consider ThreadPoolExecutor When Threads Are Necessary for Concurrency
Item 77: Mix Threads and Coroutines to Ease the Transition to asyncio
Item 78: Maximize Responsiveness of asyncio Event Loops with async-Friendly Worker Threads
Item 80: Take Advantage of Each Block in try/except/else/finally
Item 81: assert Internal Assumptions and raise Missed Expectations
Item 82: Consider contextlib and with Statements for Reusable try/finally Behavior
Item 86: Understand the Difference Between Exception and BaseException
Item 88: Consider Explicitly Chaining Exceptions to Clarify Tracebacks
Item 89: Always Pass Resources into Generators and Have Callers Clean Them Up Outside
Item 91: Avoid exec and eval Unless You’re Building a Developer Tool
Item 93: Optimize Performance-Critical Code Using timeit Microbenchmarks
Item 94: Know When and How to Replace Python with Another Programming Language
Item 95: Consider ctypes to Rapidly Integrate with Native Libraries
Item 96: Consider Extension Modules to Maximize Performance and Ergonomics
Item 97: Rely on Precompiled Bytecode and File System Caching to Improve Startup Time
Item 98: Lazy-Load Modules with Dynamic Imports to Reduce Startup Time
Item 99: Consider memoryview and bytearray for Zero-Copy Interactions with bytes
Chapter 13 Testing and Debugging
Item 110: Isolate Tests from Each Other with setUp, tearDown, setUpModule, and tearDownModule
Item 112: Encapsulate Dependencies to Facilitate Mocking and Testing
Item 113: Use assertAlmostEqual to Control Precision in Floating Point Tests
Item 115: Use tracemalloc to Understand Memory Usage and Leaks
Item 117: Use Virtual Environments for Isolated and Reproducible Dependencies
Item 118: Write Docstrings for Every Function, Class, and Module
Item 119: Use Packages to Organize Modules and Provide Stable APIs
Item 120: Consider Module-Scoped Code to Configure Deployment Environments
Item 121: Define a Root Exception to Insulate Callers from APIs
Item 124: Consider Static Analysis via typing to Obviate Bugs
Item 125: Prefer Open Source Projects for Bundling Python Programs over zipimport and zipapp