Index
Thinking in Python
Index
A
ABC: 20 Rethinking Objects, What Is Polymorphism?; 20 Rethinking Objects, Abstract Base Classes; 24 Template Method, Hooks and the Misspelled Override; 26 Factory, Self Registration
abc.ABCMeta: 17 Metaprogramming
- Ability: 46 Stateless, The Effect Type
- abstract coupling: 21 Design Patterns, Coupling
- Abstract Factory: 21 Design Patterns, Pattern Taxonomy; 26 Factory; 26 Factory, Abstract Factories; 26 Factory, Which Factory to Use; 29 Changing the Interface, Façade; 39 Pattern Catalog, Finding a Pattern by Problem; 39 Pattern Catalog, Creational (GoF); 47 Stateless in Practice, The Unmatched Cast
- abstract syntax tree: 34 Composite and Interpreter, Interpreter; 34 Composite and Interpreter, Operators That Build Nodes
@abstractmethod: 13 Pattern Matching, The Inheritance Version; 17 Metaprogramming, Attributes on a Function; 17 Metaprogramming, The Four Families; 20 Rethinking Objects, Abstract Base Classes; 24 Template Method, Hooks and the Misspelled Override; 24 Template Method, What Anchors the Algorithm; 25 Surrogate, What the Implementation Supplies; 26 Factory, Abstract Factories
__abstractmethods__: 17 Metaprogramming, Attributes on a Function
accept(): 33 Visitor, The Classic Visitor; 33 Visitor, Two Departures from the Classic Shape; 33 Visitor, The Pythonic Visitor: singledispatch; 33 Visitor, Where Visitor Still Fits; 33 Visitor, One Dispatch Is Enough; 34 Composite and Interpreter, New Operations, Same Tree; 37 Pattern Refactoring, One singledispatch Function per Operation
- accessors: 46 Stateless, Built-in Dependencies; 46 Stateless, An Interface Instead of a Base Class; 47 Stateless in Practice, Abilities Are Not Special; 47 Stateless in Practice, The Toolkit
accumulate(): 41 Toolkits, accumulate; 41 Toolkits, Choosing From the Toolkits
- Active Object: 39 Pattern Catalog, Finding a Pattern by Problem; 39 Pattern Catalog, Concurrency (POSA and others)
- Active Record: 39 Pattern Catalog, Finding a Pattern by Problem; 39 Pattern Catalog, Enterprise Application (Fowler)
- ad-hoc polymorphism: 20 Rethinking Objects, What Is Polymorphism?
- Adapter: 29 Changing the Interface, Adapter; 29 Changing the Interface, Adapter in Python; 29 Changing the Interface
- among the wrappers: 14 Decorators, The Decorator Pattern; 25 Surrogate, What the Implementation Supplies; 29 Changing the Interface, Distinguishing the Wrappers
- from structural typing: 20 Rethinking Objects, Protocols Generalize, Composition Adapts
- moving a coupling edge: 21 Design Patterns, A Pattern Moves an Edge
__add__(): 32 Multiple Dispatching; 32 Multiple Dispatching, Operators Dispatch Twice; 32 Multiple Dispatching, Turning One Unknown Type Into a Second Dispatch; 34 Composite and Interpreter, Interpreter; 34 Composite and Interpreter, Operators That Build Nodes; 34 Composite and Interpreter, Simplification Rewrites the Tree
__aenter__(): 15 Context Managers, The Async Protocol
__aexit__(): 15 Context Managers, The Async Protocol
- Aggregator: 39 Pattern Catalog, Finding a Pattern by Problem; 39 Pattern Catalog, Integration and Messaging (Hohpe and Woolf); 01 Introduction, Resources
- algebraic effect tracking: 44 Effect Management, Effect Management for Python?; A Effect Tracking, The Tracking Problem; 47 Stateless in Practice, What Survives the Library; A Effect Tracking, Why a Native System Tracks Best; A Effect Tracking, Tracking Is Not Management
- algebraic effects: 44 Effect Management, Native Effect Management; 44 Effect Management, Custom AI Languages with Effects; 47 Stateless in Practice, State as an Ability; 47 Stateless in Practice, 3. Handlers cannot capture the continuation; A Effect Tracking, The Tracking Problem; A Effect Tracking, Tracking Is Not Management
__all__: 06 Modules and Packages, What a Module Exports; 29 Changing the Interface, Façade; 42 Error Handling, Composing by Hand
- Ambassador: 39 Pattern Catalog, Finding a Pattern by Problem; 39 Pattern Catalog, Distributed and Cloud
- Amdahl's Law: 19 Concurrency, Why Speedup Isn't Linear; 19 Concurrency, Guidelines
__annotate__: 14 Decorators, wraps Keeps the Runtime Interface; 17 Metaprogramming, The Core Functions
__annotate_func__: 17 Metaprogramming, The Core Functions; 17 Metaprogramming, The Tool in Use
Annotated: A Effect Tracking, A Row Inside Annotated; 01 Introduction, How the Book Fits Together; 08 Static Types, Aliases and Distinct Types; A Effect Tracking; A Effect Tracking, The Tracking Problem; A Effect Tracking, Why a Native System Tracks Best; A Effect Tracking, What a Checker for the Row Must Do; A Effect Tracking, Tracking Is Not Management; B An Effect Checker; B An Effect Checker, Facts About a Function; B An Effect Checker, What the Checker Resolves, and What It Cannot See
annotationlib: 17 Metaprogramming, Reading Annotations Before Their Names Exist; 17 Metaprogramming, Building display_object()
annotationlib.ForwardRef: 17 Metaprogramming, Reading Annotations Before Their Names Exist
__annotations__: 06 Modules and Packages, Circular Imports; 09 Class Attributes, Declaring Shared State with ClassVar; 12 Data Classes as Types, A: Annotations Only; 12 Data Classes as Types, D: A Real ClassVar; B An Effect Checker, Effect Names and the Table
__annotations_cache__: 17 Metaprogramming, The Core Functions; 17 Metaprogramming, The Tool in Use
- API Gateway: 39 Pattern Catalog, Distributed and Cloud
argparse.ArgumentParser: 26 Factory, Builder
- argument: 05 Functions
array: 03 Containers, namedtuple; 18 Performance, Array Instead of List; 18 Performance, Vectorize with NumPy; 18 Performance, Choosing a Strategy
asdict(): 12 Data Classes as Types, More Data Class Tools; 12 Data Classes as Types, Serializing to JSON; 20 Rethinking Objects, Protocols; 28 Data Transfer Objects, Which Should You Use?; 36 Memento, Mementos That Outlive the Process
assert_never(): 08 Static Types, Typing Decorators and Directives; 13 Pattern Matching, Exhaustive Matching; 13 Pattern Matching, When Not to Match; 13 Pattern Matching, The match Version; 13 Pattern Matching, The Expression Problem; 17 Metaprogramming, The Four Families; 20 Rethinking Objects, Pattern Matching on a Union; 26 Factory; 33 Visitor, The Pythonic Visitor: singledispatch; 34 Composite and Interpreter, A Composite of Data Classes; 34 Composite and Interpreter, The Nodes and the Operators Base; 37 Pattern Refactoring, The First Cut: Checking Every Type; 47 Stateless in Practice, Catching the Whole Channel
AssertionError: 08 Static Types, Typing Decorators and Directives; 13 Pattern Matching, Exhaustive Matching; 15 Context Managers, The expected Manager; 15 Context Managers, The expect() Function; 17 Metaprogramming, The Four Families; 43 Confidence, Property-Based Testing; 43 Confidence, Shrinking a Failure; B An Effect Checker, Facts About a Function
ast: 33 Visitor, Two Departures from the Classic Shape; 34 Composite and Interpreter, Interpreter; A Effect Tracking, Resolve Every Call; B An Effect Checker, Effect Names and the Table; B An Effect Checker, From a Call to a Name; B An Effect Checker, Facts About a Function
ast.Call: B An Effect Checker, From a Call to a Name; B An Effect Checker, Facts About a Function
ast.NodeVisitor: 33 Visitor, Two Departures from the Classic Shape; 34 Composite and Interpreter, Interpreter; B An Effect Checker, From a Call to a Name
ast.walk(): B An Effect Checker, From a Call to a Name; B An Effect Checker, Facts About a Function
astuple(): 12 Data Classes as Types, More Data Class Tools; 28 Data Transfer Objects, Returning Multiple Values
asynccontextmanager: 15 Context Managers, The Async Protocol; 15 Context Managers, An Empty Pool Blocks the Borrower
- asynchrony: 19 Concurrency; 19 Concurrency,
async def, await, and the Event Loop; 19 Concurrency, Concurrency Is Not Easy; 44 Effect Management, Effect Management for Python?; 47 Stateless in Practice, What Survives the Library
asyncio.Barrier: 19 Concurrency, Concurrency Is Not Easy
asyncio.BoundedSemaphore: 19 Concurrency, Semaphores
asyncio.CancelledError: 19 Concurrency, Structured Concurrency with TaskGroup; 19 Concurrency, Bounding a Wait with asyncio.timeout(); 19 Concurrency, Guidelines
asyncio.Future: 19 Concurrency, Structured Concurrency with TaskGroup; 19 Concurrency, One await, Any Backend
asyncio.Lock: 19 Concurrency, A Single Thread Still Races; 19 Concurrency, Locks; 19 Concurrency, Deadlock; 19 Concurrency, The GIL Does Not Prevent Races; 19 Concurrency, Guidelines
asyncio.open_connection(): 19 Concurrency, A Real Socket
asyncio.start_server(): 19 Concurrency, A Real Socket
asyncio.timeout(): 19 Concurrency, Bounding a Wait with asyncio.timeout()
asyncio.to_thread(): 19 Concurrency, Escaping to a Thread; 19 Concurrency, Locks; 19 Concurrency, Context That Follows the Call Chain; 19 Concurrency, Threads Overlap Waits, Not Computing; 19 Concurrency, One await, Any Backend; 19 Concurrency, Are Threads Still Necessary?; 19 Concurrency, Guidelines
asyncio.wait_for(): 19 Concurrency, Bounding a Wait with asyncio.timeout(); 19 Concurrency, Deadlock
atexit: 10 Cleanup, weakref.finalize() as a Backstop; 10 Cleanup, The self.close Trap; 30 Observer, Setting the Responders at Construction
auto(): 12 Data Classes as Types, Mixing a Type into an Enum; 31 State Machines, A Vending Machine
- awaitable: 19 Concurrency,
async def, await, and the Event Loop; 19 Concurrency, time.sleep() Stops the Loop; 19 Concurrency, Bounding a Wait with asyncio.timeout(); 19 Concurrency, One await, Any Backend; 30 Observer, Observer and I/O; 45 Generators, The Driver You Already Use; 46 Stateless, Waiting on a Coroutine; 46 Stateless, Emptying the Channels; 47 Stateless in Practice, Running Effects in Parallel; 47 Stateless in Practice, The Toolkit
B
- Balking: 39 Pattern Catalog, Concurrency (POSA and others)
- bare annotation: 09 Class Attributes, A Bare Annotation Declares, It Does Not Create; 12 Data Classes as Types,
A: Annotations Only; 07 Classes; 12 Data Classes as Types, D: A Real ClassVar; 20 Rethinking Objects, Protocols Generalize, Composition Adapts; 35 Flyweight, A Known Set: Enum; 38 Simulation, The Rat and the Blackboard
- base case: 41 Toolkits, Recursion
BaseException: 04 Control Flow, Errors and Exceptions; 15 Context Managers, The Protocol; 15 Context Managers, The __exit__() Arguments; 15 Context Managers, The expected Manager; 19 Concurrency, Structured Concurrency with TaskGroup; 19 Concurrency, Failures as Values with gather(); 19 Concurrency, Guidelines; 42 Error Handling, Attaching Context to an Exception
batched: 41 Toolkits, batched; 41 Toolkits, Composing the Pieces; 41 Toolkits, Choosing From the Toolkits
- Behavioral: 21 Design Patterns, Pattern Taxonomy; 39 Pattern Catalog; 39 Pattern Catalog, Behavioral (GoF); 21 Design Patterns, Coupling
- Biased reference counting: 19 Concurrency, Free Threading
bin(): 02 Tour, Numbers and Arithmetic; 37 Pattern Refactoring, Let a Dictionary Do the Sorting
bisect: 03 Containers, namedtuple; 18 Performance, Bisect; 18 Performance, Scan, Bisect, or Hash; 18 Performance, Lazy Evaluation with Generators
- black-box: 11 Testing, White-Box and Black-Box Tests
- blackboard: 38 Simulation, Rats & Mazes; 38 Simulation, The Rat and the Blackboard; 39 Pattern Catalog, Architectural (POSA); 38 Simulation; 38 Simulation, Rooms, Robots, and the Item Factory
- blocked: 19 Concurrency; 19 Concurrency, Coordinating Threads with Queues; 19 Concurrency, Measuring the Time
__bool__(): 02 Tour, Booleans, None, and Truthiness
- Borg: 23 Singleton, Borg: Singleton by Inheritance; 12 Data Classes as Types, Inheritance and the Generated
__init__(); 23 Singleton, The Classic Implementations; 23 Singleton, Which Should You Use?; 39 Pattern Catalog, Other Patterns and Idioms
- bottom type: 46 Stateless, The Effect Type
- bound: 08 Static Types, Type Parameters
- bound method: 27 Function Objects, A Bound Method as a Command
- built on each attribute lookup: 17 Metaprogramming, Attributes on a Function; 18 Performance, Write Idiomatic Python; 30 Observer, Lapsed Listeners
- compared for equality: 30 Observer, Testing the Broadcaster
- keeping its instance alive: 10 Cleanup,
weakref.finalize() as a Backstop; 10 Cleanup, The self.close Trap; 27 Function Objects, A Bound Method as a Command; 30 Observer, Lapsed Listeners
break: 04 Control Flow, Loops; 04 Control Flow, The Loop else Clause; 04 Control Flow, Pattern Matching; 04 Control Flow, Errors and Exceptions; 13 Pattern Matching, Matching Values; 18 Performance, JIT Compilation with Numba; 18 Performance, Converting a Slow Function to Rust; 47 Stateless in Practice, Switching Implementations Mid-Run
- Bridge: 39 Pattern Catalog, Structural (GoF)
- Broker: 39 Pattern Catalog, Architectural (POSA)
BufferError: 18 Performance, Memory View
- Builder: 26 Factory, Builder; 14 Decorators, The Decorator Pattern; 21 Design Patterns, Pattern Taxonomy; 26 Factory; 26 Factory, Which Factory to Use; 38 Simulation, Building the Maze in Stages; 39 Pattern Catalog, Finding a Pattern by Problem; 39 Pattern Catalog, Creational (GoF)
built: 17 Metaprogramming, Building Each Class on First Lookup; 17 Metaprogramming, __init__() versus __new__() in a Metaclass; 18 Performance, The CPython JIT; 25 Surrogate, Virtual Proxy; 26 Factory, Builder; 27 Function Objects, A Tagged Bus: Handlers That Name Their Event; 30 Observer, Decorated Responders; B An Effect Checker, Facts About a Function
builtins: 17 Metaprogramming, Pickling Generated Classes; B An Effect Checker, Effect Names and the Table; B An Effect Checker, From a Call to a Name; B An Effect Checker, Facts About a Function; B An Effect Checker, Rows to a Fixed Point; B An Effect Checker, What the Checker Resolves, and What It Cannot See
builtins.dir.rmdir: B An Effect Checker, What the Checker Resolves, and What It Cannot See
builtins.Start: 17 Metaprogramming, Pickling Generated Classes
builtins.str.read_text: B An Effect Checker, What the Checker Resolves, and What It Cannot See
builtins.str.upper: B An Effect Checker, Facts About a Function
__builtins__: 17 Metaprogramming, Generating Classes with exec()
- Bulkhead: 39 Pattern Catalog, Finding a Pattern by Problem; 39 Pattern Catalog, Distributed and Cloud; 47 Stateless in Practice, 5. Much of a mature Effect system is missing
bytearray: 13 Pattern Matching, Sequence Patterns; 13 Pattern Matching, Built-in Types and Subclasses; 18 Performance, Memory View
bytes: 08 Static Types, Basic Types; 13 Pattern Matching, Sequence Patterns; 13 Pattern Matching, Built-in Types and Subclasses; 18 Performance, When Slots Does Not Fit; 18 Performance, Memory View; 19 Concurrency, Measuring the Memory; 29 Changing the Interface, Adapter in Python; 43 Confidence, Property-Based Testing; 43 Confidence, Shrinking a Failure; 45 Generators, The Driver You Already Use
C
- C3 linearization: 07 Classes, Method Resolution Order; 20 Rethinking Objects, Protocols
- C++: 20 Rethinking Objects; 20 Rethinking Objects, Evolution; 01 Introduction
- classes and fields: 07 Classes; 07 Classes, Inheritance; 07 Classes, Calling the Base Constructor; 09 Class Attributes; 09 Class Attributes, Class Attributes Are Not Default Values; 21 Design Patterns, The Edge Python Deletes; 26 Factory, Builder
- exceptions: 04 Control Flow, Exception Chaining; 44 Effect Management, Catch the Exception You Expect; 02 Tour, Indentation and Blocks; 02 Tour, t-Strings; 03 Containers, Two List Traps; 03 Containers, Tuples and Unpacking; 04 Control Flow; 04 Control Flow, Errors and Exceptions; 05 Functions; 06 Modules and Packages, Watching the Deferral; 08 Static Types, Type Parameters; 08 Static Types, Basic Types; 10 Cleanup, Why
__del__() Is Not Cleanup; 10 Cleanup, An __init__() That Fails Leaks the Resource; 11 Testing, Testing for Exceptions; 12 Data Classes as Types, check() and TypeFailure; 12 Data Classes as Types, A Class Is Not a Type; 13 Pattern Matching, Guards; 14 Decorators, Decorators That Take Arguments; 15 Context Managers; 15 Context Managers, A Basic Context Manager; 15 Context Managers, The Protocol; 15 Context Managers, Guaranteed Cleanup; 15 Context Managers, The __exit__() Arguments; 15 Context Managers, The expected Manager; 15 Context Managers, The expect() Function; 15 Context Managers, Context Manager as Decorator; 15 Context Managers, The Async Protocol; 15 Context Managers, An Object Pool; 15 Context Managers, What the Skeleton Leaves Out; 18 Performance, Measuring One Function with sys.monitoring; 19 Concurrency, Structured Concurrency with TaskGroup; 19 Concurrency, Bounding a Wait with asyncio.timeout(); 19 Concurrency, What a Process Pool Requires; 19 Concurrency, Coordinating Threads with Queues; 19 Concurrency, Sharing an Iterator Between Threads; 20 Rethinking Objects, Evolution; 20 Rethinking Objects, Protocols; 22 Iterators, The Body Waits for the First next(); 22 Iterators, An Exhausted Generator Is Silently Empty; 22 Iterators, Reusable Algorithms; 22 Iterators, Asking Consumes an Item; 24 Template Method, Substitutability; 25 Surrogate, A Surrogate Is Not Its Implementation; 25 Surrogate, Protection Proxy; 30 Observer, Disconnecting During a Notification; 30 Observer, Raising an Exception; 30 Observer, A Failing Responder Orphans the Rest; 32 Multiple Dispatching, Operators Dispatch Twice; 34 Composite and Interpreter, Operators That Build Nodes; 37 Pattern Refactoring, The First Cut: Checking Every Type; 37 Pattern Refactoring, One singledispatch Function per Operation; 40 Foundations, Pure Functions; 42 Error Handling; 42 Error Handling, Exceptions Discard Partial Calculations; 42 Error Handling, Total Functions; 42 Error Handling, Composing by Hand; 42 Error Handling, Combining Multiple Results; 42 Error Handling, Turning Exceptions into Results; 42 Error Handling, Matching on the Error; 42 Error Handling, Attaching Context to an Exception; 44 Effect Management, Are Exceptions Impure?; 44 Effect Management, Converting Effectful to Pure; 44 Effect Management, Return a Result Type; 45 Generators, Annotating a Generator; 45 Generators, throw() and close() Reach the Innermost Generator; 46 Stateless, The Effect Definition; 46 Stateless, Supplying the Dependency; 46 Stateless, Churn in Every Signature; 46 Stateless, Declaring a Failure with @throws; 46 Stateless, A Failure Travels as a Value; 46 Stateless, Declaring Is Not Handling; 46 Stateless, Catching Is Not Handling; 46 Stateless, Turning an Error Into a Value; 47 Stateless in Practice; 47 Stateless in Practice, A Coin Toss; 47 Stateless in Practice, Switching Implementations Mid-Run; 47 Stateless in Practice, Composing a Program; 47 Stateless in Practice, Running Effects in Parallel; 47 Stateless in Practice, The Toolkit; 47 Stateless in Practice, 1. Nothing stops an undeclared Effect; 47 Stateless in Practice, 3. Handlers cannot capture the continuation; 47 Stateless in Practice, What Survives the Library; A Effect Tracking, Why a Native System Tracks Best; A Effect Tracking, Find a Place to Run
- in GoF Design Patterns: 21 Design Patterns; 23 Singleton, The Classic Implementations; 27 Function Objects, Choosing the Lightest Callable
- static typing: 08 Static Types; 32 Multiple Dispatching; 37 Pattern Refactoring, The First Cut: Checking Every Type
- syntax: 02 Tour, How to Read the Examples; 02 Tour, Indentation and Blocks; 04 Control Flow, Conditionals
cached_property: 07 Classes, Caching with cached_property; 41 Toolkits, cached_property; 14 Decorators, Decorators You Already Know; 18 Performance, Caching; 18 Performance, When Slots Does Not Fit; 41 Toolkits, cache
__call__(): 14 Decorators, Decorators as Classes; 14 Decorators, A Stateless Class-Form Decorator; 14 Decorators, A Class-Form Decorator with State; 14 Decorators, A Class-Form Decorator with Arguments; 14 Decorators, A Limitation: Methods Need a Descriptor; 14 Decorators, Function Form or Class Form?; 14 Decorators, What @ Does Not Require; 17 Metaprogramming, Intercepting Instance Creation; 17 Metaprogramming, When You Still Need a Metaclass; 17 Metaprogramming, Which Hook for Which Job; 23 Singleton, Singleton by Class Decorator; 26 Factory, Explicit Registration with a Protocol; 27 Function Objects, A Callable Object as a Command; 27 Function Objects, Chain of Responsibility: Choosing the Handler at Runtime; 27 Function Objects, A Tagged Bus: Handlers That Name Their Event; 27 Function Objects, Choosing the Lightest Callable
callable: 08 Static Types, Containers; 14 Decorators, Decorators That Take Arguments; 14 Decorators, Decorators With Optional Parentheses; 17 Metaprogramming, Generating Classes with exec(); 17 Metaprogramming, The Core Functions; 17 Metaprogramming, Building display_object(); 18 Performance, A Decorator for the Default; 22 Iterators, Asking Consumes an Item; 25 Surrogate, Smart Reference; 30 Observer, The Pythonic Observer; 40 Foundations, Leaving a Gap with Placeholder
Callable[P, R]: 14 Decorators, **P and R Keep the Static Interface; 14 Decorators, A Coroutine Function Needs an async Wrapper; 14 Decorators, Decorators That Take Arguments; 46 Stateless, An Effect Runs Once
- declares no __name__: 14 Decorators, What
@ Does Not Require; 27 Function Objects, Chain of Responsibility: Choosing the Handler at Runtime
- in place of an interface: 14 Decorators, What
@ Does Not Require; 21 Design Patterns, When a Pattern Dissolves; 21 Design Patterns, What One Part Knows About Another; 21 Design Patterns, The Edge Python Deletes; 27 Function Objects, Chain of Responsibility: Choosing the Handler at Runtime; 27 Function Objects, A Tagged Bus: Handlers That Name Their Event
- named by a type alias: 27 Function Objects, Command: Choosing the Operation at Runtime
- capture pattern: 13 Pattern Matching, Alternatives and Capture; 13 Pattern Matching, A Bare Name Captures, a Dotted Name Compares; 13 Pattern Matching, Built-in Types and Subclasses
- caretaker: 36 Memento; 36 Memento, The Caretaker: a Generic History; 36 Memento, The Classic Memento; 36 Memento, Why
Memento Is a Class; 36 Memento, Immutability
cast(): 08 Static Types, Typing Decorators and Directives; 17 Metaprogramming, @dataclass_transform Is a Claim; 35 Flyweight, Typing the Symbol Set; 43 Confidence, A Confidence Spectrum; 46 Stateless, What the Type Checker Reads; 46 Stateless, An Interface Instead of a Base Class; B An Effect Checker, Facts About a Function
__cause__: 04 Control Flow, Exception Chaining; 42 Error Handling, Attaching Context to an Exception
chain: 41 Toolkits, chain; 16 Comprehensions, Unpacking in Comprehensions; 22 Iterators, Reusable Algorithms; 27 Function Objects, Strategy: Choosing the Algorithm at Runtime; 27 Function Objects, Chain of Responsibility: Choosing the Handler at Runtime; 40 Foundations, Functions as First-Class Objects
- Chain of Responsibility: 27 Function Objects, Chain of Responsibility: Choosing the Handler at Runtime; 21 Design Patterns, Pattern Taxonomy; 21 Design Patterns, Coupling; 27 Function Objects; 27 Function Objects, An Event Bus: Handlers Keyed by Type; 27 Function Objects, Choosing the Lightest Callable
- checked exceptions: 44 Effect Management, Catch the Exception You Expect; 46 Stateless, Churn in Every Signature; A Effect Tracking, The Tracking Problem
- Circuit Breaker: 39 Pattern Catalog, Finding a Pattern by Problem; 39 Pattern Catalog, Distributed and Cloud; 47 Stateless in Practice, 5. Much of a mature Effect system is missing
- class adapter: 29 Changing the Interface, Three Places for the Adaptation
- class attribute: 09 Class Attributes, Class Attributes Are Not Default Values
- class decorators: 17 Metaprogramming; 17 Metaprogramming, When You Still Need a Metaclass
__class__: 17 Metaprogramming, Generating Classes with type(); 17 Metaprogramming, A Family of Generated Classes; 17 Metaprogramming, Generating Classes with exec(); 17 Metaprogramming, The Tool in Use; 25 Surrogate, A Surrogate Is Not Its Implementation; 28 Data Transfer Objects, A NamedTuple Is Still a Tuple; 33 Visitor, Two Departures from the Classic Shape
- classes: 17 Metaprogramming
@classmethod: 07 Classes, Static and Class Methods; 08 Static Types, The Self Return Type; 09 Class Attributes, type(self) Forks the Counter; 14 Decorators, Decorators You Already Know; 17 Metaprogramming, When You Still Need a Metaclass; 24 Template Method, Hooks and the Misspelled Override; 26 Factory, Alternative Constructors Are Factories; 26 Factory, Hazards of Self Registration; 26 Factory, Which Factory to Use; 37 Pattern Refactoring, The Trash Hierarchy
close(): 10 Cleanup, An Explicit close() and a with Block; 10 Cleanup, Why __del__() Is Not Cleanup; 10 Cleanup, weakref.finalize() as a Backstop; 10 Cleanup, The Rule; 15 Context Managers, Context Manager as Decorator; 15 Context Managers, The contextlib Toolkit; 45 Generators, throw() and close() Reach the Innermost Generator
generator.close(): 45 Generators, throw() and close() Reach the Innermost Generator; 19 Concurrency, Sharing an Iterator Between Threads; 45 Generators, The Driver You Already Use
- closed: 08 Static Types, Typing
**kwargs with a TypedDict; 37 Pattern Refactoring, The First Cut: Checking Every Type
- closure: 14 Decorators, What
@ Does; 40 Foundations, Closures
- carrying configuration: 14 Decorators, A Class-Form Decorator with State; 17 Metaprogramming, Attributes on a Function; 27 Function Objects, Strategy: Choosing the Algorithm at Runtime; 27 Function Objects, Choosing the Lightest Callable
- late binding in a loop: 27 Function Objects, The Late-Binding Trap
cls.__name__: 14 Decorators, Decorating Classes; 17 Metaprogramming, Self-Registration of Subclasses; 26 Factory, Hazards of Self Registration; 33 Visitor, The Pythonic Visitor: singledispatch
cmp_to_key: 41 Toolkits, cmp_to_key
- cohesion: 21 Design Patterns, Design Principles; 30 Observer, Deciding What Matters
Collection: 22 Iterators, An Exhausted Generator Is Silently Empty
combinations(): 41 Toolkits, permutations and combinations; 41 Toolkits, Case Study: Pairing Rounds; 41 Toolkits, Groups of Any Size
combinations_with_replacement(): 41 Toolkits, permutations and combinations
- Command: 27 Function Objects, Command: Choosing the Operation at Runtime; 27 Function Objects, A Bound Method as a Command; 27 Function Objects, A Callable Object as a Command; 21 Design Patterns, Coupling; 27 Function Objects; 36 Memento, Immutability; 36 Memento, The Caretaker: a Generic History; 39 Pattern Catalog, Finding a Pattern by Problem
- Command Query Responsibility Segregation: 39 Pattern Catalog, Distributed and Cloud
complex: 08 Static Types, Basic Types
- Composite: 34 Composite and Interpreter, The Classic Composite; 34 Composite and Interpreter, A Composite of Data Classes; 21 Design Patterns, Pattern Taxonomy; 34 Composite and Interpreter; 34 Composite and Interpreter, Interpreter; 34 Composite and Interpreter, Simplification Rewrites the Tree; 39 Pattern Catalog, Finding a Pattern by Problem
- comprehension: 03 Containers, Two List Traps; 16 Comprehensions
compress: 41 Toolkits, compress
- concurrency: 19 Concurrency
concurrent.futures.Future: 19 Concurrency, One await, Any Backend
- conditional expression: 04 Control Flow, Conditionals; 02 Tour, Booleans, None, and Truthiness; 16 Comprehensions, Nested Comprehensions
- constraint: 08 Static Types, Type Parameters; 01 Introduction, Who This Book Is For; 12 Data Classes as Types, Enums Are Types Too; 40 Foundations, Immutability in Annotations; 42 Error Handling, A Result Type; 44 Effect Management, Native Effect Management; A Effect Tracking, Why a Native System Tracks Best
- constructor: 07 Classes
- constructor function: 23 Singleton, When You Want a Class, Cache the Instance; 23 Singleton, Tests, Threads, and Locks; 35 Flyweight, Intrinsic and Extrinsic State; 41 Toolkits,
cache
__contains__(): 22 Iterators, An Exhausted Generator Is Silently Empty
- Content-Based Router: 39 Pattern Catalog, Finding a Pattern by Problem; 39 Pattern Catalog, Integration and Messaging (Hohpe and Woolf)
- context manager: 04 Control Flow, Context Managers; 15 Context Managers, The Protocol
- a temporary directory: 16 Comprehensions, Supplying the Input Iterable; 16 Comprehensions, The Gap Between Creation and Consumption
- as a decorator: 15 Context Managers, Context Manager as Decorator; 14 Decorators, Function Form or Class Form?; 15 Context Managers, The
contextlib Toolkit
- combining several: 15 Context Managers, Combining Context Managers; 47 Stateless in Practice, Running Effects in Parallel
- for tracing a span: 19 Concurrency, Overlapping the Waits; 19 Concurrency, Context That Follows the Call Chain
- from a generator: 15 Context Managers, A Basic Context Manager
- returning to a pool: 15 Context Managers, An Object Pool
- context switching: 19 Concurrency
__context__: 04 Control Flow, Exception Chaining; 15 Context Managers, Guaranteed Cleanup; 42 Error Handling, Attaching Context to an Exception
ContextDecorator: 15 Context Managers, Context Manager as Decorator; 15 Context Managers, The contextlib Toolkit; 15 Context Managers, Choosing a Form
contextlib: 15 Context Managers, The contextlib Toolkit; 02 Tour, Naming Conventions; 11 Testing, Isolating Tests from the World; 15 Context Managers, A Basic Context Manager; 15 Context Managers, The __exit__() Arguments; 15 Context Managers, Context Manager as Decorator; 15 Context Managers, Combining Context Managers; 15 Context Managers, The Async Protocol; 15 Context Managers, An Object Pool; 15 Context Managers, Choosing a Form; 18 Performance, Numbers on Your Machine; 47 Stateless in Practice, Switching Implementations Mid-Run
contextlib.redirect_stdout: 02 Tour, Naming Conventions; 11 Testing, Isolating Tests from the World
@contextmanager: 10 Cleanup, An Explicit close() and a with Block; 15 Context Managers, A Basic Context Manager; 15 Context Managers, The Protocol; 15 Context Managers, The __exit__() Arguments; 15 Context Managers, Context Manager as Decorator; 15 Context Managers, The contextlib Toolkit; 15 Context Managers, The Async Protocol; 15 Context Managers, An Object Pool; 15 Context Managers, Choosing a Form; 45 Generators, throw() and close() Reach the Innermost Generator
ContextVar: 11 Testing, The Clock; 19 Concurrency, Context That Follows the Call Chain; 19 Concurrency, Guidelines; 39 Pattern Catalog, Concurrency (POSA and others); 44 Effect Management, Effects by Hand; A Effect Tracking, Subtract What a Handler Discharges; A Effect Tracking, Find a Place to Run
contextvars.copy_context(): 19 Concurrency, Context That Follows the Call Chain
- continuation: 44 Effect Management, Native Effect Management; 47 Stateless in Practice, 3. Handlers cannot capture the continuation; A Effect Tracking, Tracking Is Not Management
continue: 04 Control Flow, Loops; 04 Control Flow, The Loop else Clause; 04 Control Flow, Errors and Exceptions; 17 Metaprogramming, Building display_object()
Coord: 08 Static Types, Naming Types: The type Statement; 20 Rethinking Objects, Protocols Generalize, Composition Adapts; 29 Changing the Interface, Adapter in Python; 30 Observer, The Model; 38 Simulation, The Rat and the Blackboard; 38 Simulation, Testing Full Coverage; 38 Simulation, Watching the Pack; 38 Simulation, Rooms, Robots, and the Item Factory
copy: 12 Data Classes as Types, copy() and deepcopy() Skip the Constructor; 18 Performance, Memory View; 20 Rethinking Objects, Plugging Leaks Is Tedious; 25 Surrogate, The Recursion Trap; 26 Factory, Prototype; 29 Changing the Interface, Adapter in Python; 36 Memento, The Classic Memento; see also deepcopy(), replace()
- copy-on-write: 25 Surrogate, What Proxy Solves
- coroutine function: 14 Decorators, A Coroutine Function Needs an
async Wrapper; 19 Concurrency, async def, await, and the Event Loop; 15 Context Managers, The expect() Function; 15 Context Managers, The Async Protocol
- coroutine object: 19 Concurrency,
async def, await, and the Event Loop; 14 Decorators, A Coroutine Function Needs an async Wrapper; 44 Effect Management, Effect Management for Python?; 45 Generators, The Driver You Already Use
- coroutines: 19 Concurrency; 19 Concurrency,
async def, await, and the Event Loop; 19 Concurrency, Threads Overlap Waits, Not Computing; 30 Observer, Observer and I/O
Counter: 03 Containers, Counter; 03 Containers, Specialized Containers; 10 Cleanup, Why __del__() Is Not Cleanup; 10 Cleanup, Watching Objects Without Holding Them; 18 Performance, Measuring One Function with sys.monitoring; 30 Observer, Document-View and MVC; 41 Toolkits, Groups of Any Size; 41 Toolkits, history Is Mutable State
- covariant: 08 Static Types, Variance; 08 Static Types, Containers
cProfile: 18 Performance, Reading a cProfile Report; 18 Performance, Profilers; 18 Performance, The Sampling Profiler
- CPU-bound: 19 Concurrency, I/O-Bound vs CPU-Bound; 18 Performance, Try a Faster Platform; 19 Concurrency, Parallelism; 19 Concurrency, Free Threading; 19 Concurrency, Subinterpreters; 19 Concurrency, Are Threads Still Necessary?; 19 Concurrency, Guidelines
- Creational: 21 Design Patterns, Pattern Taxonomy; 39 Pattern Catalog; 39 Pattern Catalog, Creational (GoF); 26 Factory; 26 Factory, Builder
- cross-cutting concerns: 14 Decorators
- Curiously Recurring Template Pattern: 39 Pattern Catalog, Language and Implementation Idioms
current: 12 Data Classes as Types, Defining __replace__(); 18 Performance, Numbers on Your Machine; 19 Concurrency, Context That Follows the Call Chain; 19 Concurrency, What a Process Pool Requires; 19 Concurrency, Sharing an Iterator Between Threads; 22 Iterators, What tee() Buffers; 38 Simulation, Building the Maze in Stages
current_item(): 22 Iterators, first() and current_item() Rebuild the List
cycle: 41 Toolkits, cycle; 10 Cleanup, Reference Cycles Delay Destruction; 34 Composite and Interpreter, Simplification Rewrites the Tree; 38 Simulation, Watching It Happen
D
- data class: 12 Data Classes as Types, Data Classes
- data descriptor: 17 Metaprogramming, A Descriptor That Learns Its Name; 30 Observer, Decorated Responders
- Data Mapper: 39 Pattern Catalog, Finding a Pattern by Problem; 39 Pattern Catalog, Enterprise Application (Fowler)
- Data Transfer Object: 21 Design Patterns, Pattern Taxonomy; 28 Data Transfer Objects; 39 Pattern Catalog, Finding a Pattern by Problem; 39 Pattern Catalog, Enterprise Application (Fowler); 39 Pattern Catalog, Other Patterns and Idioms
@dataclass: 28 Data Transfer Objects, @dataclass; 12 Data Classes as Types, Data Classes; 12 Data Classes as Types, C: The Same Annotations, Decorated; 31 State Machines, The Engine; see also data class, record
@dataclass(eq=False): 12 Data Classes as Types, check() and TypeFailure; 22 Iterators, A Type-Checking Iterator; 30 Observer, Decorated Responders; 34 Composite and Interpreter, Operators That Build Nodes
@dataclass(frozen=True): 12 Data Classes as Types, Immutability; 12 Data Classes as Types, Normalizing a Frozen Field; 12 Data Classes as Types, Frozen and Plain Data Classes Do Not Mix; 18 Performance, Slots; 20 Rethinking Objects, The Immutability Solution; 27 Function Objects, A Tagged Bus: Handlers That Name Their Event; 28 Data Transfer Objects, NamedTuple; 28 Data Transfer Objects, A NamedTuple Is Still a Tuple; 40 Foundations, Immutability in Annotations
@dataclass(kw_only=True): 12 Data Classes as Types, Inheritance and the Generated __init__(); 12 Data Classes as Types, More Data Class Tools
@dataclass(order=True): 18 Performance, A Decorator for the Default; 28 Data Transfer Objects, A NamedTuple Is Still a Tuple; 41 Toolkits, total_ordering
@dataclass(slots=True): 09 Class Attributes, Two Dictionaries, One Lookup; 12 Data Classes as Types, Immutability; 18 Performance, Slots; 18 Performance, A Decorator for the Default; 18 Performance, When Slots Does Not Fit; 18 Performance, Choosing a Strategy; 20 Rethinking Objects, The Immutability Solution; 27 Function Objects, A Tagged Bus: Handlers That Name Their Event; 35 Flyweight, A Pool That Does Not Leak
dataclasses.field(): 12 Data Classes as Types, When an Enum Beats a Data Class; 12 Data Classes as Types, Defaults Built Fresh, Not Shared; 26 Factory, The Pythonic Factory: a Dictionary; 38 Simulation, The Rat and the Blackboard
__post_init__(): 12 Data Classes as Types, A Type Is a Set of Values; 12 Data Classes as Types, Normalizing a Frozen Field; 12 Data Classes as Types, Inheritance and the Generated __init__(); 12 Data Classes as Types, copy() and deepcopy() Skip the Constructor; 23 Singleton, Borg: Singleton by Inheritance; 30 Observer, The Pythonic Observer; 36 Memento, A Class That Changes After the Save; B An Effect Checker, What the Checker Resolves, and What It Cannot See
__dataclass_fields__: 17 Metaprogramming, The Tool in Use
__dataclass_params__: 17 Metaprogramming, The Tool in Use
@dataclass_transform: 17 Metaprogramming, @dataclass_transform Is a Claim; 18 Performance, A Decorator for the Default; 27 Function Objects, A Tagged Bus: Handlers That Name Their Event; 30 Observer, Decorated Responders
date: 12 Data Classes as Types, Enums Are Types Too; 12 Data Classes as Types, The General Form of replace()
datetime: 11 Testing, The Clock; 12 Data Classes as Types, Enums Are Types Too; 12 Data Classes as Types, The General Form of replace(); 36 Memento, Restoring Part of a State; 47 Stateless in Practice, A Clock; 47 Stateless in Practice, A Clock That Crosses Midnight; 47 Stateless in Practice, Switching Implementations Mid-Run; 47 Stateless in Practice, retry() and a Flaky Database; 47 Stateless in Practice, repeat() and memoize()
datetime.fromisoformat(): 26 Factory, Alternative Constructors Are Factories
- Dead Letter Channel: 39 Pattern Catalog, Finding a Pattern by Problem; 39 Pattern Catalog, Integration and Messaging (Hohpe and Woolf)
- deadlock: 19 Concurrency, Deadlock and Livelock; 19 Concurrency, Deadlock; 10 Cleanup, Why
__del__() Is Not Cleanup; 19 Concurrency, Livelock; 19 Concurrency, Raw multiprocessing; 19 Concurrency, Guidelines
- debug specifier: 02 Tour, f-Strings
- declarative: 43 Confidence, A Confidence Spectrum; 18 Performance, Vectorize with NumPy
- decorator: 07 Classes, Marking Overrides with
@override; 14 Decorators, The Decorator Pattern; 15 Context Managers, Context Manager as Decorator; 21 Design Patterns, A Pattern Moves an Edge; 29 Changing the Interface; 29 Changing the Interface, Distinguishing the Wrappers; 39 Pattern Catalog, Finding a Pattern by Problem; 02 Tour, Numbers and Arithmetic; 07 Classes, Inheritance; 09 Class Attributes, Real Per-Object Defaults; 11 Testing, Fixtures Replace Setup and Teardown; 12 Data Classes as Types, Data Classes; 12 Data Classes as Types, Comparing Ordinary Classes and Data Classes; 12 Data Classes as Types, Enums Are Types Too; 14 Decorators; 14 Decorators, What @ Does; 14 Decorators, Maintaining the Wrapped Interface; 14 Decorators, **P and R Keep the Static Interface; 14 Decorators, A Coroutine Function Needs an async Wrapper; 14 Decorators, Decorators That Take Arguments; 14 Decorators, Decorators With Optional Parentheses; 14 Decorators, Stacking Decorators; 14 Decorators, Decorators as Classes; 14 Decorators, A Stateless Class-Form Decorator; 14 Decorators, A Class-Form Decorator with State; 14 Decorators, A Class-Form Decorator with Arguments; 14 Decorators, A Limitation: Methods Need a Descriptor; 14 Decorators, Function Form or Class Form?; 14 Decorators, Decorating Classes; 14 Decorators, What @ Does Not Require; 15 Context Managers, A Basic Context Manager; 15 Context Managers, The contextlib Toolkit; 17 Metaprogramming, Self-Registration of Subclasses; 17 Metaprogramming, Attributes on a Function; 17 Metaprogramming, Making a Class Final; 17 Metaprogramming, The Four Families; 17 Metaprogramming, @dataclass_transform Is a Claim; 17 Metaprogramming, When You Still Need a Metaclass; 17 Metaprogramming, Reading Annotations Before Their Names Exist; 17 Metaprogramming, Which Hook for Which Job; 18 Performance, The CPython JIT; 18 Performance, A Decorator for the Default; 18 Performance, JIT Compilation with Numba; 19 Concurrency, Sharing an Iterator Between Threads; 23 Singleton, Singleton by Class Decorator; 23 Singleton, Which Should You Use?; 24 Template Method, The Anchored Algorithm; 24 Template Method, Hooks and the Misspelled Override; 24 Template Method, Passing the Steps as Functions; 26 Factory, Explicit Registration with a Protocol; 27 Function Objects, A Tagged Bus: Handlers That Name Their Event; 28 Data Transfer Objects, A NamedTuple Is Still a Tuple; 29 Changing the Interface, Deprecating the Old Interface; 30 Observer, Setting the Responders at Construction; 30 Observer, Decorated Responders; 33 Visitor, The Pythonic Visitor: singledispatch; 35 Flyweight, Sharing, Not Caching; 37 Pattern Refactoring, The Trash Hierarchy; 40 Foundations, Higher-Order Functions; 41 Toolkits, wraps; 41 Toolkits, Recursion; 42 Error Handling, Turning Exceptions into Results; 42 Error Handling, The returns Library; 44 Effect Management, Return a Result Type; 46 Stateless, Built-in Dependencies; 46 Stateless, An Effect Runs Once; 46 Stateless, An Interface Instead of a Base Class; 46 Stateless, Declaring Is Not Handling; 47 Stateless in Practice, Switching Implementations Mid-Run; 47 Stateless in Practice, Composing a Program; 47 Stateless in Practice, The Success Path; 47 Stateless in Practice, Failing from Inside an Effect; 47 Stateless in Practice, retry() and a Flaky Database; A Effect Tracking, Decide What Untracked Code Performs; A Effect Tracking, Find a Place to Run; B An Effect Checker, What the Checker Resolves, and What It Cannot See
- in the standard library: 14 Decorators, Decorators You Already Know
- keeping the wrapped interface: 14 Decorators, Maintaining the Wrapped Interface
- stacking: 14 Decorators, Stacking Decorators
- taking arguments: 14 Decorators, Decorators That Take Arguments; 14 Decorators, Decorators With Optional Parentheses; 14 Decorators, A Class-Form Decorator with Arguments
- written as a class: 14 Decorators, Decorators as Classes; 14 Decorators, A Stateless Class-Form Decorator; 14 Decorators, A Class-Form Decorator with State; 14 Decorators, Function Form or Class Form?
deepcopy(): 12 Data Classes as Types, copy() and deepcopy() Skip the Constructor; 02 Tour, Variables and References; 20 Rethinking Objects, Plugging Leaks Is Tedious; 26 Factory, Prototype; 36 Memento, A Snapshot Is Not a Reference; 36 Memento, The Classic Memento; 39 Pattern Catalog, Patterns Python Absorbed
__deepcopy__(): 26 Factory, Prototype
default_factory: 09 Class Attributes, A Shared Mutable Value; 12 Data Classes as Types, Defaults Built Fresh, Not Shared; 35 Flyweight, Interning in the Constructor; 38 Simulation, The Rat and the Blackboard
defaultdict: 03 Containers, defaultdict; 03 Containers, Specialized Containers; 27 Function Objects, An Event Bus: Handlers Keyed by Type; 35 Flyweight, Interning in the Constructor
__defaults__: 05 Functions, The Mutable Default Trap
del: 03 Containers, Growing, Shrinking, and Sorting; 03 Containers, Dictionaries; 07 Classes, Caching with cached_property; 10 Cleanup, Why __del__() Is Not Cleanup; 10 Cleanup, weakref.finalize() as a Backstop; 10 Cleanup, The Rule; 30 Observer, Lapsed Listeners; 35 Flyweight, A Pool That Does Not Leak; 41 Toolkits, cached_property
__del__(): 10 Cleanup, Why __del__() Is Not Cleanup; 10 Cleanup, Reference Cycles Delay Destruction; 10 Cleanup, Reliable Alternatives; 10 Cleanup, weakref.finalize() as a Backstop; 10 Cleanup, Watching Objects Without Holding Them; 10 Cleanup, The Rule; 15 Context Managers
- delayed binding: 44 Effect Management, Tracking and Management; 44 Effect Management, Effects by Hand; 44 Effect Management, Library Effect Management; 44 Effect Management, Custom AI Languages with Effects; 44 Effect Management, Effect Management for Python?; 46 Stateless; 46 Stateless, Swapping the Implementation; A Effect Tracking, Tracking Is Not Management
__delete__(): 17 Metaprogramming, Learning a Name with __set_name__()
- dependency injection: 11 Testing, Random Numbers; 39 Pattern Catalog, Finding a Pattern by Problem; 39 Pattern Catalog, Dependency Supply; 46 Stateless, Dependency Injection; 44 Effect Management, Effects by Hand; 46 Stateless, Declaring a Dependency; 46 Stateless, Layering Handlers
DeprecationWarning: 29 Changing the Interface, Deprecating the Old Interface
deque: 03 Containers, deque; 03 Containers, Specialized Containers; 18 Performance, Choose Better Algorithms and Data Structures; 38 Simulation, Choosing the Path; 45 Generators, The Driver You Already Use
describe(): 41 Toolkits, singledispatchmethod; 42 Error Handling, Matching on the Error; B An Effect Checker, The Check
- descriptor: 14 Decorators, A Limitation: Methods Need a Descriptor; 17 Metaprogramming, Learning a Name with
__set_name__(); 17 Metaprogramming, A Descriptor That Learns Its Name; 17 Metaprogramming, A Descriptor That Validates
- functions as: 14 Decorators, A Limitation: Methods Need a Descriptor; 14 Decorators, Decorators You Already Know; 17 Metaprogramming, Learning a Name with
__set_name__(); 17 Metaprogramming, Writing a Metaclass; 41 Toolkits, partialmethod
- skipped by inspection: 17 Metaprogramming, The Core Functions; 17 Metaprogramming, Sorting Members into Attributes and Methods
- Design by Contract: 12 Data Classes as Types, A Class Is Not a Type
- design patterns: 21 Design Patterns; 39 Pattern Catalog
- diamond problem: 20 Rethinking Objects, Protocols
difflib: 24 Template Method, Hooks and the Misspelled Override
dir(): 06 Modules and Packages, Packages; 06 Modules and Packages, What a Module Exports; B An Effect Checker, What the Checker Resolves, and What It Cannot See
- director: 26 Factory, Builder; 01 Introduction, AI Trigger Warning
- discriminated: 42 Error Handling, A Result Type
- Dispatcher: 39 Pattern Catalog, Concurrency (POSA and others); 27 Function Objects, A Tagged Bus: Handlers That Name Their Event; 32 Multiple Dispatching, The
singledispatchmethod Trap; 33 Visitor, The Pythonic Visitor: singledispatch; 37 Pattern Refactoring, One singledispatch Function per Operation
display_object(): 17 Metaprogramming, display_object() Reference; 17 Metaprogramming, Building display_object(); 07 Classes; 09 Class Attributes, Two Dictionaries, One Lookup; 09 Class Attributes, Declaring Shared State with ClassVar; 12 Data Classes as Types, Data Classes; 12 Data Classes as Types, Comparing Ordinary Classes and Data Classes; 17 Metaprogramming, Writing a Metaclass; 17 Metaprogramming, The Core Functions; 17 Metaprogramming, Sorting Members into Attributes and Methods
__doc__: 05 Functions; 14 Decorators, wraps Keeps the Runtime Interface; 14 Decorators, A Stateless Class-Form Decorator; 17 Metaprogramming, The Tool in Use; 41 Toolkits, wraps
- docstring: 05 Functions; 14 Decorators,
wraps Keeps the Runtime Interface; 15 Context Managers, Context Manager as Decorator; 15 Context Managers, The contextlib Toolkit; 17 Metaprogramming, The inspect Module; 17 Metaprogramming, The Core Functions; 41 Toolkits, wraps
- Document-View: 30 Observer; 30 Observer, Document-View and MVC
- Domain Model: 39 Pattern Catalog, Finding a Pattern by Problem; 39 Pattern Catalog, Enterprise Application (Fowler)
- Double Dispatch: 39 Pattern Catalog, Finding a Pattern by Problem; 39 Pattern Catalog, Other Patterns and Idioms; 32 Multiple Dispatching, Methods or Table; 33 Visitor, The Classic Visitor; 33 Visitor, One Dispatch Is Enough; 37 Pattern Refactoring, One
singledispatch Function per Operation
- double dispatching: 32 Multiple Dispatching; 32 Multiple Dispatching, Operators Dispatch Twice
- double-checked locking: 23 Singleton, Double-Checked Locking and Eager Creation; 39 Pattern Catalog, Concurrency (POSA and others)
- Draining: 19 Concurrency, Raw
multiprocessing
drive(): 45 Generators, A Generator Is a Description; 45 Generators, All Three Channels; 45 Generators, Composing Is Not Interpreting; 45 Generators, The Driver You Already Use; 46 Stateless, The Simplest Effect; 47 Stateless in Practice, Abilities Are Not Special
- driver: 45 Generators
dropwhile(): 41 Toolkits, dropwhile
- duck typing: 08 Static Types, Structural Typing with Protocols
- dunder: 02 Tour, Booleans, None, and Truthiness; 06 Modules and Packages; 07 Classes; 07 Classes, String Representation; 12 Data Classes as Types, Data Classes; 12 Data Classes as Types, Defining
__replace__(); 25 Surrogate, Special Methods Bypass __getattr__()
- dynamic typing: 02 Tour, Variables and References; 20 Rethinking Objects, Dynamic Typing; 07 Classes, Inheritance; 08 Static Types, Structural Typing with Protocols; 20 Rethinking Objects, Protocols
E
- eagerly: 23 Singleton, Tests, Threads, and Locks; 06 Modules and Packages, Lazy Imports; 16 Comprehensions, Generator Expressions; 23 Singleton, Lazy Creation; 26 Factory, Hazards of Self Registration; 35 Flyweight, Interning in the Constructor; 44 Effect Management, Library Effect Management
- Effect: 01 Introduction, How the Book Fits Together; 44 Effect Management, What Is an Effect?
- Effect Management System: 44 Effect Management; 44 Effect Management, Effect Management Systems; 44 Effect Management, Tracking and Management; 44 Effect Management, Native Effect Management; 44 Effect Management, Effect Management for Python?; 46 Stateless
- Effect polymorphism: A Effect Tracking, Why a Native System Tracks Best; A Effect Tracking, Tracking Is Not Management
- Effect row: 44 Effect Management, Native Effect Management; 44 Effect Management, Library Effect Management; 44 Effect Management, Effect Management for Python?; A Effect Tracking, The Tracking Problem; B An Effect Checker, Rows to a Fixed Point
- Effect tracking: 44 Effect Management, Tracking and Management; 01 Introduction, How the Book Fits Together; 44 Effect Management, Native Effect Management; 44 Effect Management, Effect Management for Python?; 44 Effect Management, Effects Are the Next Barrier; 46 Stateless; 47 Stateless in Practice, 5. Much of a mature Effect system is missing; A Effect Tracking
- Effect variable: A Effect Tracking, Why a Native System Tracks Best; A Effect Tracking, Propagate Through Callbacks; B An Effect Checker, What the Checker Resolves, and What It Cannot See
elif: 04 Control Flow, Conditionals; 19 Concurrency, Structured Concurrency with TaskGroup; 26 Factory; 38 Simulation, The Rat and the Blackboard; 38 Simulation, Rooms, Robots, and the Item Factory; 40 Foundations, Functions as First-Class Objects; B An Effect Checker, Facts About a Function
- Ellipsis: 04 Control Flow, Placeholders:
pass and ...
- emergence: 38 Simulation, The Less the Agents Know
__enter__(): 04 Control Flow, Context Managers; 10 Cleanup, An Explicit close() and a with Block; 10 Cleanup, An __init__() That Fails Leaks the Resource; 15 Context Managers, The Protocol; 15 Context Managers, Guaranteed Cleanup; 15 Context Managers, The __exit__() Arguments; 15 Context Managers, The expected Manager; 15 Context Managers, Context Manager as Decorator; 15 Context Managers, Combining Context Managers; 15 Context Managers, The contextlib Toolkit; 15 Context Managers, The Async Protocol; 15 Context Managers, Choosing a Form; 19 Concurrency, Overlapping the Waits; 19 Concurrency, Semaphores
- Enterprise Integration Patterns: 39 Pattern Catalog
Enum: 12 Data Classes as Types, When an Enum Beats a Data Class; 08 Static Types, Naming Types: The type Statement; 12 Data Classes as Types, Enums Are Types Too; 12 Data Classes as Types, Mixing a Type into an Enum; 13 Pattern Matching, A Bare Name Captures, a Dotted Name Compares; 13 Pattern Matching, When Not to Match; 17 Metaprogramming; 26 Factory; 26 Factory, Alternative Constructors Are Factories; 30 Observer, The Model; 31 State Machines, Mousetrap States; 31 State Machines, Table-Driven State Machine; 31 State Machines, The Engine; 31 State Machines, A Vending Machine; 31 State Machines, Which Design Should You Use?; 35 Flyweight, A Known Set: Enum; 35 Flyweight, Choosing a Flyweight and Its Pool; 38 Simulation, The Rat and the Blackboard; 38 Simulation, Rooms, Robots, and the Item Factory
enum.EnumType: 17 Metaprogramming
enumerate(): 04 Control Flow, range(), enumerate(), and zip(); 12 Data Classes as Types, When an Enum Beats a Data Class; 38 Simulation, Building the Maze in Stages; 41 Toolkits, Groups of Any Size
- enumeration: 12 Data Classes as Types, Enums Are Types Too; 31 State Machines, Each State Decides; 32 Multiple Dispatching
__eq__(): 12 Data Classes as Types, check() and TypeFailure; 12 Data Classes as Types, Data Classes; 12 Data Classes as Types, A: Annotations Only; 14 Decorators, Decorators You Already Know; 17 Metaprogramming, The Tool in Use; 18 Performance, Slots; 22 Iterators, A Type-Checking Iterator; 28 Data Transfer Objects, A NamedTuple Is Still a Tuple; 34 Composite and Interpreter, Operators That Build Nodes; 35 Flyweight, Intrinsic and Extrinsic State; 35 Flyweight, Interning in the Constructor; 38 Simulation, Choosing the Path; 41 Toolkits, total_ordering
eval(): 17 Metaprogramming, The Injection Risk; 26 Factory, Factory Objects; B An Effect Checker, Effect Names and the Table; B An Effect Checker, From a Call to a Name
- event bus: 27 Function Objects, An Event Bus: Handlers Keyed by Type; 31 State Machines, A Vending Machine; 37 Pattern Refactoring, Let a Dictionary Do the Sorting
- event loop: 19 Concurrency,
async def, await, and the Event Loop
- Event Sourcing: 39 Pattern Catalog, Finding a Pattern by Problem; 39 Pattern Catalog, Distributed and Cloud
- exception group: 19 Concurrency, Structured Concurrency with
TaskGroup
- exception specifications: 44 Effect Management, Catch the Exception You Expect
ExceptionGroup: 19 Concurrency, Structured Concurrency with TaskGroup; 19 Concurrency, Guidelines
exec(): 17 Metaprogramming, Generating Classes with exec(); 17 Metaprogramming, The Injection Risk; 17 Metaprogramming, Pickling Generated Classes; 17 Metaprogramming, Which Hook for Which Job; 18 Performance, Reading a cProfile Report; B An Effect Checker, Effect Names and the Table
Executor: 19 Concurrency, One Executor Interface, Three Pools; 19 Concurrency, What a Process Pool Requires; 19 Concurrency, One await, Any Backend; 47 Stateless in Practice, Running Effects in Parallel; 47 Stateless in Practice, The Toolkit; 47 Stateless in Practice, 6. fork() drops the error channel
exit: 15 Context Managers, A Basic Context Manager; 15 Context Managers, The Protocol; 15 Context Managers, Guaranteed Cleanup; 17 Metaprogramming, Which Hook for Which Job
__exit__(): 15 Context Managers, The __exit__() Arguments; 04 Control Flow, Context Managers; 10 Cleanup, An Explicit close() and a with Block; 10 Cleanup, An __init__() That Fails Leaks the Resource; 10 Cleanup, The Rule; 15 Context Managers, A Basic Context Manager; 15 Context Managers, The Protocol; 15 Context Managers, Guaranteed Cleanup; 15 Context Managers, The expected Manager; 15 Context Managers, Context Manager as Decorator; 15 Context Managers, The contextlib Toolkit; 15 Context Managers, The Async Protocol; 15 Context Managers, Choosing a Form; 19 Concurrency, Overlapping the Waits; 19 Concurrency, One await, Any Backend; 45 Generators, throw() and close() Reach the Innermost Generator
ExitStack: 15 Context Managers, Guaranteed Cleanup; 15 Context Managers, Combining Context Managers; 15 Context Managers, The contextlib Toolkit; 15 Context Managers, The Async Protocol; 15 Context Managers, Choosing a Form; 47 Stateless in Practice, Running Effects in Parallel; 47 Stateless in Practice, What Survives the Library
- expression problem: 13 Pattern Matching, The Expression Problem; 34 Composite and Interpreter, A Composite of Data Classes; 20 Rethinking Objects, Pattern Matching on a Union; 37 Pattern Refactoring, Adding Operations: Visitor, and Why Python Skips It; 37 Pattern Refactoring, One
singledispatch Function per Operation
extend(): 02 Tour, Numbers and Arithmetic; 03 Containers, Growing, Shrinking, and Sorting; 05 Functions, The Mutable Default Trap; 17 Metaprogramming, Generating Classes with type(); 20 Rethinking Objects, Prefer Composition to Inheritance; 34 Composite and Interpreter, A Template Is a Tree
- extrinsic state: 35 Flyweight; 35 Flyweight, Intrinsic and Extrinsic State; 35 Flyweight, Choosing a Flyweight and Its Pool
F
- f-strings: 02 Tour, f-Strings; 02 Tour, t-Strings
- Façade: 29 Changing the Interface, Façade; 06 Modules and Packages, What a Module Exports; 14 Decorators, The Decorator Pattern; 29 Changing the Interface; 29 Changing the Interface, Distinguishing the Wrappers; 39 Pattern Catalog, Finding a Pattern by Problem; 39 Pattern Catalog, Structural (GoF)
- factory: 03 Containers,
defaultdict; 26 Factory
- Factory Method: 26 Factory, Simple Factory Method; 21 Design Patterns, Pattern Taxonomy; 21 Design Patterns, A Pattern Moves an Edge; 26 Factory; 26 Factory, Subclasses Choose the Type; 39 Pattern Catalog, Finding a Pattern by Problem; 39 Pattern Catalog, Creational (GoF); 39 Pattern Catalog, Patterns Python Absorbed
- factory object: 26 Factory, Factory Objects; 26 Factory, Abstract Factories; 26 Factory, Which Factory to Use
- fallback: 25 Surrogate, Forwarding with
__getattr__()
- as a default value: 02 Tour, Booleans, None, and Truthiness; 33 Visitor, The Pythonic Visitor: singledispatch; 37 Pattern Refactoring, One
singledispatch Function per Operation; 46 Stateless, Layering Handlers; 47 Stateless in Practice, 5. Much of a mature Effect system is missing
- in attribute lookup: 07 Classes, String Representation; 09 Class Attributes, Two Dictionaries, One Lookup; 09 Class Attributes, Declaring Shared State with ClassVar; 09 Class Attributes, A
ClassVar With No Value Declares Too; 25 Surrogate, Forwarding Writes; 29 Changing the Interface, Adapter in Python
fetch(): 19 Concurrency, async def, await, and the Event Loop; 19 Concurrency, Structured Concurrency with TaskGroup; 19 Concurrency, Failures as Values with gather(); 19 Concurrency, One await, Any Backend; 46 Stateless, Waiting on a Coroutine; 47 Stateless in Practice, Composing a Program; 47 Stateless in Practice, Failing from Inside an Effect; B An Effect Checker, Effects for Code You Don't Own
fields: 09 Class Attributes, Real Per-Object Defaults; 12 Data Classes as Types, C: The Same Annotations, Decorated; 28 Data Transfer Objects, NamedTuple; 30 Observer, Decorated Responders
FileNotFoundError: 11 Testing, Filesystem and Environment; 46 Stateless, Built-in Dependencies; 47 Stateless in Practice, The Toolkit
filter(): 16 Comprehensions, The map() and filter() Equivalent; 04 Control Flow, Comprehensions; 22 Iterators, Reusable Algorithms; 40 Foundations, Higher-Order Functions; 40 Foundations, Putting the Pieces Together; 41 Toolkits, takewhile; 41 Toolkits, filterfalse
filterfalse(): 41 Toolkits, filterfalse; 41 Toolkits, dropwhile
Final: 08 Static Types, Constants with Final; 08 Static Types, Constants and Class Variables; 08 Static Types, Typing Decorators and Directives; 17 Metaprogramming, Attributes on a Function; 17 Metaprogramming, Making a Class Final; 17 Metaprogramming, The Four Families; 24 Template Method, The Anchored Algorithm; 24 Template Method, Hooks and the Misspelled Override; 24 Template Method, Passing the Steps as Functions; 24 Template Method, What Anchors the Algorithm; 40 Foundations, Immutability in Annotations; 42 Error Handling, A Result Type
- beside ClassVar: 09 Class Attributes, What
ClassVar Catches
- on a mutable value: 08 Static Types, Constants with Final; 40 Foundations, Immutability in Annotations
- resolved by the effect checker: B An Effect Checker, From a Call to a Name; B An Effect Checker, Facts About a Function; B An Effect Checker, What the Checker Resolves, and What It Cannot See
__final__: 17 Metaprogramming, Attributes on a Function; 17 Metaprogramming, Making a Class Final; 17 Metaprogramming, The Four Families; 24 Template Method, The Anchored Algorithm; 24 Template Method, Hooks and the Misspelled Override
finalize(): 10 Cleanup, weakref.finalize() as a Backstop; 10 Cleanup, The self.close Trap; 10 Cleanup, A Slotted Class Needs __weakref__; 10 Cleanup, Watching Objects Without Holding Them; 10 Cleanup, The Rule
finally: 04 Control Flow, Errors and Exceptions; 04 Control Flow, Context Managers; 15 Context Managers, A Basic Context Manager; 15 Context Managers, Guaranteed Cleanup; 15 Context Managers, The contextlib Toolkit; 15 Context Managers, An Object Pool; 15 Context Managers, Choosing a Form; 18 Performance, Numbers on Your Machine; 19 Concurrency, Context That Follows the Call Chain; 45 Generators, throw() and close() Reach the Innermost Generator
- first-class: 40 Foundations, Functions as First-Class Objects; 17 Metaprogramming,
@dataclass_transform Is a Claim; 23 Singleton, Which Should You Use?; 24 Template Method, Passing the Steps as Functions; 26 Factory, The Pythonic Factory: a Dictionary; 31 State Machines, A Vending Machine
- Fluent Interface: 39 Pattern Catalog, Other Patterns and Idioms
- Flyweight: 35 Flyweight, Choosing a Flyweight and Its Pool; 35 Flyweight; 35 Flyweight, A Pool That Does Not Leak; 39 Pattern Catalog, Finding a Pattern by Problem
fnmatch(): B An Effect Checker, Effect Names and the Table
fnmatchcase(): B An Effect Checker, Effect Names and the Table
fork(): 47 Stateless in Practice, 6. fork() drops the error channel; 47 Stateless in Practice, Running Effects in Parallel; 47 Stateless in Practice, The Toolkit; 47 Stateless in Practice, 5. Much of a mature Effect system is missing
format(): 02 Tour, f-Strings; 02 Tour, t-Strings; 17 Metaprogramming, Reading Annotations Before Their Names Exist; 17 Metaprogramming, Building display_object(); 17 Metaprogramming, The Tool in Use
__format__(): 07 Classes, String Representation; 17 Metaprogramming, The Tool in Use
- forward reference: 08 Static Types, Self and Forward References
__forward_arg__: 17 Metaprogramming, Reading Annotations Before Their Names Exist
- fragile base class: 20 Rethinking Objects, Prefer Composition to Inheritance
- free-threaded: 19 Concurrency, Free Threading; 18 Performance, Try a Faster Platform; 19 Concurrency, Subinterpreters; 19 Concurrency, Guidelines; 43 Confidence, Automatic Parallelism
- Front Controller: 39 Pattern Catalog, Finding a Pattern by Problem; 39 Pattern Catalog, Enterprise Application (Fowler)
frozendict: 03 Containers, frozendict; 03 Containers, Immutability; 13 Pattern Matching, Built-in Types and Subclasses; 18 Performance, Choose Better Algorithms and Data Structures
FrozenInstanceError: 12 Data Classes as Types, Immutability; 12 Data Classes as Types, Normalizing a Frozen Field; 18 Performance, Slots; 20 Rethinking Objects, The Immutability Solution; 36 Memento, The Classic Memento; 36 Memento, Why Memento Is a Class; 36 Memento, A Class That Changes After the Save
frozenset: 03 Containers, Immutability; 03 Containers, frozendict; 08 Static Types, Constants with Final; 08 Static Types, Containers; 13 Pattern Matching, Built-in Types and Subclasses; 17 Metaprogramming, The Core Functions; 18 Performance, Choose Better Algorithms and Data Structures; 40 Foundations, Immutability; B An Effect Checker, Effect Names and the Table
- Function Composition: 39 Pattern Catalog, Functional Idioms; 40 Foundations, Composing Functions
- function object: 27 Function Objects; 39 Pattern Catalog, Other Patterns and Idioms; 27 Function Objects, Chain of Responsibility: Choosing the Handler at Runtime; 27 Function Objects, A Tagged Bus: Handlers That Name Their Event
- at runtime: 05 Functions, The Mutable Default Trap; 07 Classes, Marking Overrides with
@override; 09 Class Attributes, Two Dictionaries, One Lookup; 14 Decorators, wraps Keeps the Runtime Interface; 17 Metaprogramming, Building display_object(); 40 Foundations, Closures
- function overloading: 20 Rethinking Objects, What Is Polymorphism?; 32 Multiple Dispatching
functools._lru_cache_wrapper: 35 Flyweight, Typing the Symbol Set
functools.WRAPPER_ASSIGNMENTS: 14 Decorators, wraps Keeps the Runtime Interface
- Future/Promise: 39 Pattern Catalog, Finding a Pattern by Problem; 39 Pattern Catalog, Concurrency (POSA and others)
G
- Gateway: 39 Pattern Catalog, Finding a Pattern by Problem; 39 Pattern Catalog, Enterprise Application (Fowler); 39 Pattern Catalog, Distributed and Cloud
gather(): 19 Concurrency, Failures as Values with gather(); 19 Concurrency, async def, await, and the Event Loop; 19 Concurrency, A Real Socket; 19 Concurrency, Escaping to a Thread; 19 Concurrency, Structured Concurrency with TaskGroup; 19 Concurrency, Deadlock; 19 Concurrency, Measuring the Time; 19 Concurrency, Guidelines; 19 Concurrency, Concurrency Is Not Easy; 30 Observer, Observer and I/O; 30 Observer, Disconnecting During an Async Notification; 30 Observer, A Failing Responder Orphans the Rest
gc.collect(): 10 Cleanup, Reference Cycles Delay Destruction; 10 Cleanup, The self.close Trap; 10 Cleanup, The Rule; 30 Observer, Lapsed Listeners
gc.disable(): 10 Cleanup, Reference Cycles Delay Destruction; 10 Cleanup, The Rule
gc.enable(): 10 Cleanup, Reference Cycles Delay Destruction; 18 Performance, Trusting a Measurement
gc.garbage: 10 Cleanup, Reference Cycles Delay Destruction
gc.get_referrers(): 10 Cleanup, Reference Cycles Delay Destruction
__ge__: 17 Metaprogramming, The Tool in Use; 41 Toolkits, total_ordering
- generator: 22 Iterators, Generators; 26 Factory, Simple Factory Method
- generator expression: 16 Comprehensions, Generator Expressions; 16 Comprehensions, A Generator Expression Runs Once; 16 Comprehensions, The Gap Between Creation and Consumption; 16 Comprehensions, Unpacking in Comprehensions; 16 Comprehensions, Choosing a Form; 22 Iterators, Reusable Algorithms
GeneratorExit: 45 Generators, throw() and close() Reach the Innermost Generator
Generic: 08 Static Types, **P and the Older TypeVar Syntax; 08 Static Types, Generics; 17 Metaprogramming, When You Still Need a Metaclass; 30 Observer, Decorated Responders
__get__(): 14 Decorators, A Limitation: Methods Need a Descriptor; 14 Decorators, Function Form or Class Form?; 14 Decorators, Decorators You Already Know; 17 Metaprogramming, Learning a Name with __set_name__(); 17 Metaprogramming, A Descriptor That Learns Its Name; 17 Metaprogramming, A Descriptor That Validates
get_annotations(): 17 Metaprogramming, The Core Functions; 17 Metaprogramming, Sorting Members into Attributes and Methods; 17 Metaprogramming, Reading Annotations Before Their Names Exist; 17 Metaprogramming, Building display_object(); 23 Singleton, Nothing Keeps the Class Private
get_close_matches(): 24 Template Method, Hooks and the Misspelled Override
get_type_hints(): 06 Modules and Packages, Circular Imports; A Effect Tracking, A Row Inside Annotated
getattr(): 17 Metaprogramming, Attributes on a Function; 24 Template Method, Hooks and the Misspelled Override; 32 Multiple Dispatching, Testing Both Versions; 33 Visitor, Two Departures from the Classic Shape; 36 Memento, A Deleted Field Leaves a Ghost; 42 Error Handling, Attaching Context to an Exception; A Effect Tracking, Decide What Untracked Code Performs
__getattr__(): 25 Surrogate, Forwarding with __getattr__(); 25 Surrogate, Special Methods Bypass __getattr__(); 06 Modules and Packages, Deferring an Import Before 3.15; 17 Metaprogramming, Sorting Members into Attributes and Methods; 23 Singleton, Lazy Creation; 25 Surrogate, Forwarding Writes; 25 Surrogate, The Recursion Trap; 25 Surrogate, A Surrogate Is Not Its Implementation; 25 Surrogate, Virtual Proxy; 25 Surrogate, Protection Proxy; 25 Surrogate, Smart Reference; 25 Surrogate, State; 25 Surrogate, One Surrogate, Two Intents; 28 Data Transfer Objects, A Hand-Rolled Messenger; 29 Changing the Interface, Adapter in Python; 29 Changing the Interface, Distinguishing the Wrappers; A Effect Tracking, Decide What Untracked Code Performs
__getattribute__(): 17 Metaprogramming, The Tool in Use; 25 Surrogate, Forwarding with __getattr__(); 28 Data Transfer Objects, A Hand-Rolled Messenger
__getitem__(): 17 Metaprogramming, Building Each Class on First Lookup; 17 Metaprogramming, When You Still Need a Metaclass; 18 Performance, Lazy Evaluation with Generators; 22 Iterators, Iteration Comes Built In; 22 Iterators, Reusable Algorithms
__getstate__(): 17 Metaprogramming, The Tool in Use; 29 Changing the Interface, Adapter in Python
global: 05 Functions, Names Inside a Function; 06 Modules and Packages, The Module Namespace; 17 Metaprogramming, Pickling Generated Classes; 18 Performance, Benchmark Alternatives with timeit; 23 Singleton, The First-Call Race; 40 Foundations, Closures; 43 Confidence, Referential Transparency
- Global Interpreter Lock: 19 Concurrency, Parallelism
- GoF Design Patterns: 21 Design Patterns
- as workarounds for static languages: 23 Singleton, The Classic Implementations; 23 Singleton, Which Should You Use?; 27 Function Objects, Choosing the Lightest Callable; 37 Pattern Refactoring
- its classification: 21 Design Patterns, Pattern Taxonomy; 26 Factory
- on coupling: 21 Design Patterns, Coupling; 21 Design Patterns, What One Part Knows About Another
- gradual typing: 08 Static Types, Gradual Typing; 08 Static Types, Narrowing; 08 Static Types, How Much to Annotate; 08 Static Types, Basic Types; 44 Effect Management, Effect Management for Python?; A Effect Tracking, Decide What Untracked Code Performs
groupby(): 41 Toolkits, groupby; 22 Iterators, Reusable Algorithms; 38 Simulation, Building the Maze in Stages
__gt__: 17 Metaprogramming, The Tool in Use; 41 Toolkits, total_ordering
- Guarded Suspension: 39 Pattern Catalog, Concurrency (POSA and others)
H
- Half-Sync/Half-Async: 39 Pattern Catalog, Concurrency (POSA and others)
- handler: 27 Function Objects, Chain of Responsibility: Choosing the Handler at Runtime; 44 Effect Management, Native Effect Management; A Effect Tracking, Subtract What a Handler Discharges; 04 Control Flow, Errors and Exceptions; 04 Control Flow, Exception Chaining; 12 Data Classes as Types,
check() and TypeFailure; 19 Concurrency, Structured Concurrency with TaskGroup; 27 Function Objects; 27 Function Objects, An Event Bus: Handlers Keyed by Type; 27 Function Objects, A Tagged Bus: Handlers That Name Their Event; 30 Observer, Deciding What Matters; 39 Pattern Catalog, Behavioral (GoF); 39 Pattern Catalog, Concurrency (POSA and others); 39 Pattern Catalog, Enterprise Application (Fowler); 42 Error Handling, Attaching Context to an Exception; 44 Effect Management, Effects by Hand; 44 Effect Management, Library Effect Management; 44 Effect Management, Custom AI Languages with Effects; 46 Stateless, Supplying the Dependency; 46 Stateless, Layering Handlers; 46 Stateless, What the Type Checker Reads; 46 Stateless, What isinstance() Checks; 46 Stateless, An Interface Instead of a Base Class; 46 Stateless, No Container, Three Consequences; 46 Stateless, Catching Is Not Handling; 46 Stateless, Emptying the Channels; 47 Stateless in Practice; 47 Stateless in Practice, Abilities Are Not Special; 47 Stateless in Practice, Scripting an Unpredictable Source; 47 Stateless in Practice, A Coin Toss; 47 Stateless in Practice, A Clock; 47 Stateless in Practice, A Clock That Crosses Midnight; 47 Stateless in Practice, Switching Implementations Mid-Run; 47 Stateless in Practice, Catching the Whole Channel; 47 Stateless in Practice, The Toolkit; 47 Stateless in Practice, run() Builds a Loop per Call; 47 Stateless in Practice, 2. The type checker decides what survives handling; 47 Stateless in Practice, 3. Handlers cannot capture the continuation; A Effect Tracking, The Tracking Problem; A Effect Tracking, Why a Native System Tracks Best; A Effect Tracking, Tracking Is Not Management
hasattr(): 25 Surrogate, A Surrogate Is Not Its Implementation; 25 Surrogate, Protection Proxy; 27 Function Objects, A Tagged Bus: Handlers That Name Their Event
- hash: 03 Containers, Dictionaries; 18 Performance, Scan, Bisect, or Hash; 40 Foundations, A Stable Hash and Safe Sharing; 03 Containers, Sets; 03 Containers,
frozendict; 03 Containers, Shallow Immutability; 18 Performance, Benchmark Alternatives with timeit; 18 Performance, Heap Versus Sort; 20 Rethinking Objects, Prefer Composition to Inheritance; 28 Data Transfer Objects, A NamedTuple Is Still a Tuple; 43 Confidence, Shrinking a Failure
- in dictionary and set lookup: 03 Containers, Dictionaries; 03 Containers, Sets; 18 Performance, Benchmark Alternatives with
timeit; 18 Performance, Scan, Bisect, or Hash
- of equal values: 03 Containers,
frozendict; 12 Data Classes as Types, Immutability; 20 Rethinking Objects, Prefer Composition to Inheritance; 28 Data Transfer Objects, NamedTuple; 28 Data Transfer Objects, A NamedTuple Is Still a Tuple; 36 Memento, A Deleted Field Leaves a Ghost; 38 Simulation, Choosing the Path; 40 Foundations, A Stable Hash and Safe Sharing
__hash__: 12 Data Classes as Types, Comparing Ordinary Classes and Data Classes; 12 Data Classes as Types, A: Annotations Only; 17 Metaprogramming, Building display_object(); 35 Flyweight, Interning in the Constructor; 38 Simulation, Choosing the Path
__hash__ = None: 12 Data Classes as Types, check() and TypeFailure; 12 Data Classes as Types, Data Classes; 12 Data Classes as Types, Immutability; 17 Metaprogramming, Building display_object(); 17 Metaprogramming, The Tool in Use; 22 Iterators, A Type-Checking Iterator; 40 Foundations, A Stable Hash and Safe Sharing
- hashable: 03 Containers, Dictionaries
- as a dictionary key or set member: 03 Containers, Dictionaries; 03 Containers, Immutability; 03 Containers,
frozendict; 12 Data Classes as Types, Immutability; 18 Performance, Choose Better Algorithms and Data Structures; 20 Rethinking Objects, The Immutability Solution; 28 Data Transfer Objects, NamedTuple
- cache arguments: 18 Performance, Caching; 35 Flyweight, Typing the Symbol Set; 41 Toolkits,
cache; 47 Stateless in Practice, repeat() and memoize()
- frozen data classes: 12 Data Classes as Types, Immutability; 20 Rethinking Objects, The Immutability Solution; 30 Observer, Decorated Responders; 40 Foundations, A Stable Hash and Safe Sharing
- heap: 18 Performance, Heap; 18 Performance, Heap Versus Sort; 03 Containers,
namedtuple; 18 Performance, Bisect; 19 Concurrency; 19 Concurrency, Measuring the Memory; 19 Concurrency, Measuring the Time
heapify(): 18 Performance, Heap; 18 Performance, Heap Versus Sort
heapq: 03 Containers, deque; 03 Containers, namedtuple; 18 Performance, Heap; 18 Performance, Heap Versus Sort; 19 Concurrency, Coordinating Threads with Queues
help(): 14 Decorators, wraps Keeps the Runtime Interface; 41 Toolkits, wraps
- higher-order function: 40 Foundations, Higher-Order Functions
history: 41 Toolkits, history Is Mutable State; 30 Observer, Document-View and MVC; 36 Memento, Immutability; 36 Memento, The Caretaker: a Generic History; 36 Memento, Restoring Part of a State; 41 Toolkits, Groups of Any Size; 47 Stateless in Practice, Composing a Program
- Hollywood Principle: 24 Template Method, The Anchored Algorithm
I
- I/O-bound: 19 Concurrency, I/O-Bound vs CPU-Bound; 18 Performance, Choosing a Strategy; 19 Concurrency,
async def, await, and the Event Loop; 19 Concurrency, Threads Overlap Waits, Not Computing; 19 Concurrency, Are Threads Still Necessary?
__iadd__(): 09 Class Attributes, A Shared Mutable Value; 32 Multiple Dispatching, Operators Dispatch Twice
id(): 10 Cleanup, Watching Objects Without Holding Them; 20 Rethinking Objects, Dynamic Typing; 23 Singleton, When You Want a Class, Cache the Instance; 23 Singleton, The First-Call Race; 35 Flyweight, Intrinsic and Extrinsic State; B An Effect Checker, From a Call to a Name; B An Effect Checker, Facts About a Function
- idempotence: 43 Confidence, A Family of Property Shapes
- Identity Map: 39 Pattern Catalog, Finding a Pattern by Problem; 39 Pattern Catalog, Enterprise Application (Fowler)
- immortal: 19 Concurrency, Free Threading
- immutable: 02 Tour, Variables and References; 40 Foundations, Immutability
- imperative: 43 Confidence, A Confidence Spectrum; 43 Confidence, Affordable Proof; 44 Effect Management, Library Effect Management
- imports: 19 Concurrency, What a Process Pool Requires
- inclusion polymorphism: 20 Rethinking Objects, What Is Polymorphism?
index(): 03 Containers, Indexing and Slicing; 03 Containers, Growing, Shrinking, and Sorting; 04 Control Flow, range(), enumerate(), and zip(); 17 Metaprogramming, Generating Classes with type(); 22 Iterators, first() and current_item() Rebuild the List; 30 Observer, The Model; 45 Generators, The Driver You Already Use
IndexError: 03 Containers, Indexing and Slicing; 22 Iterators, Iteration Comes Built In; 36 Memento, The Caretaker: a Generic History; 47 Stateless in Practice, A Coin Toss
__init__(): 10 Cleanup, An __init__() That Fails Leaks the Resource; 12 Data Classes as Types, Inheritance and the Generated __init__(); 07 Classes; B An Effect Checker, Facts About a Function; B An Effect Checker, What the Checker Resolves, and What It Cannot See; see also initializer, constructor
- called through super(): 07 Classes, Inheritance; 07 Classes, Calling the Base Constructor; 17 Metaprogramming, A Family of Generated Classes; 23 Singleton, Borg: Singleton by Inheritance; 24 Template Method, Don't Start the Engine in the Constructor; 30 Observer, The Classic Observer; 30 Observer, The Pythonic Observer
- generated by @dataclass: 12 Data Classes as Types, Data Classes; 12 Data Classes as Types,
D: A Real ClassVar; 12 Data Classes as Types, Inheritance and the Generated __init__(); 15 Context Managers, The Protocol; 28 Data Transfer Objects, @dataclass; 31 State Machines, The Engine
- skipped by copy(): 12 Data Classes as Types,
copy() and deepcopy() Skip the Constructor
- versus __new__(): 17 Metaprogramming,
__init__() versus __new__() in a Metaclass; 12 Data Classes as Types, A NamedTuple Cannot Validate Itself; 17 Metaprogramming, Intercepting Instance Creation; 23 Singleton, One Instance in a Class Variable; 23 Singleton, Singleton by Class Decorator; 35 Flyweight, Interning in the Constructor; 35 Flyweight, A Known Set: Enum; 36 Memento, A Class That Changes After the Save
__init_subclass__(): 14 Decorators, Decorating Classes; 17 Metaprogramming; 17 Metaprogramming, Self-Registration of Subclasses; 17 Metaprogramming, Making a Class Final; 17 Metaprogramming, When You Still Need a Metaclass; 17 Metaprogramming, Which Hook for Which Job
- checking overrides: 24 Template Method, The Anchored Algorithm; 24 Template Method, Hooks and the Misspelled Override; 24 Template Method, What Anchors the Algorithm
- registering subclasses: 26 Factory, Self Registration; 26 Factory, Hazards of Self Registration; 26 Factory, Explicit Registration with a Protocol; 37 Pattern Refactoring, The
Trash Hierarchy
- initializer: 07 Classes; 08 Static Types, Constants with Final; 08 Static Types, How Much to Annotate; 12 Data Classes as Types,
D: A Real ClassVar; 12 Data Classes as Types, Inheritance and the Generated __init__()
inspect: 17 Metaprogramming, The inspect Module; 17 Metaprogramming, Pickling Generated Classes; 17 Metaprogramming, The Four Families; 17 Metaprogramming, The Core Functions; 17 Metaprogramming, Which Hook for Which Job; 17 Metaprogramming, display_object() Reference
inspect.getattr_static(): 25 Surrogate, A Surrogate Is Not Its Implementation
inspect.getclosurevars(): 40 Foundations, Closures
inspect.getdoc(): 05 Functions; 17 Metaprogramming, The Core Functions
inspect.getgeneratorstate(): 45 Generators, A Generator Is a Description
inspect.getmembers_static(): 17 Metaprogramming, The Core Functions; 17 Metaprogramming, Sorting Members into Attributes and Methods; 17 Metaprogramming, Building display_object()
inspect.getsource(): 17 Metaprogramming, Pickling Generated Classes
inspect.isclass(): 17 Metaprogramming, The Core Functions; 17 Metaprogramming, Building display_object()
inspect.isfunction(): 17 Metaprogramming, The Core Functions
inspect.ismethod(): 17 Metaprogramming, The Core Functions
inspect.signature(): 14 Decorators, wraps Keeps the Runtime Interface; 17 Metaprogramming, The Core Functions; 17 Metaprogramming, Sorting Members into Attributes and Methods; 17 Metaprogramming, Building display_object(); 27 Function Objects, A Tagged Bus: Handlers That Name Their Event; 41 Toolkits, wraps
intern(): 35 Flyweight, Python Uses Flyweights; 35 Flyweight, A Pool That Does Not Leak
- interning: 35 Flyweight, Python Uses Flyweights; 35 Flyweight, Interning in the Constructor; 35 Flyweight, Choosing a Flyweight and Its Pool
Interpolation: 02 Tour, t-Strings; 34 Composite and Interpreter, A Template Is a Tree
- Interpreter: 34 Composite and Interpreter, Interpreter; 21 Design Patterns, Pattern Taxonomy; 34 Composite and Interpreter; 34 Composite and Interpreter, Simplification Rewrites the Tree; 34 Composite and Interpreter, A Template Is a Tree; 39 Pattern Catalog, Finding a Pattern by Problem
InterpreterPoolExecutor: 19 Concurrency, Subinterpreters; 19 Concurrency, One Executor Interface, Three Pools; 23 Singleton, A Module Is Already a Singleton
interview(): 45 Generators, Annotating a Generator; 45 Generators, A Generator Is a Description; 45 Generators, All Three Channels; 45 Generators, Composing Is Not Interpreting; 46 Stateless, Nothing Runs Yet; 47 Stateless in Practice, Abilities Are Not Special
- intrinsic state: 35 Flyweight
- invariant: 08 Static Types, Variance; 43 Confidence, A Family of Property Shapes
- condition that must hold: 01 Introduction, The Exercises; 11 Testing, Fixtures Replace Setup and Teardown; 12 Data Classes as Types,
check() and TypeFailure; 12 Data Classes as Types, A Class Is Not a Type; 17 Metaprogramming, When You Still Need a Metaclass; 41 Toolkits, zip_longest; 46 Stateless, Dependency Injection
- in variance: 08 Static Types, Containers; 09 Class Attributes, A Base Class Declares, a Subclass Supplies
- Inversion of Control: 24 Template Method, The Anchored Algorithm; 39 Pattern Catalog, Dependency Supply
IO: 15 Context Managers, The contextlib Toolkit; 44 Effect Management, Effect Management for Python?; B An Effect Checker, Effect Names and the Table
io.IOBase: 10 Cleanup, The Rule
is_dataclass(): 12 Data Classes as Types, Serializing to JSON
isinstance(): 46 Stateless, What isinstance() Checks; 13 Pattern Matching, Built-in Types and Subclasses
- against a Protocol: 08 Static Types, Structural Typing with Protocols; 08 Static Types, Structural Typing; 25 Surrogate, What the Implementation Supplies; 25 Surrogate, Forwarding with
__getattr__(); 25 Surrogate, A Surrogate Is Not Its Implementation; 46 Stateless, An Interface Instead of a Base Class; 47 Stateless in Practice, Switching Implementations Mid-Run
- in class patterns: 13 Pattern Matching, Built-in Types and Subclasses; 32 Multiple Dispatching,
match with Class Patterns
- in supply(): 46 Stateless, What
isinstance() Checks; 46 Stateless, An Interface Instead of a Base Class; 46 Stateless, When Two Implementations Match; 46 Stateless, Dependency Injection; 47 Stateless in Practice, Switching Implementations Mid-Run
- narrowing with: 08 Static Types, Narrowing
- on a surrogate: 25 Surrogate, Forwarding with
__getattr__(); 25 Surrogate, A Surrogate Is Not Its Implementation
- versus type(): 13 Pattern Matching, Built-in Types and Subclasses; 17 Metaprogramming, A Family of Generated Classes; 26 Factory, Hiding the Concrete Classes; 31 State Machines, A Vending Machine
islice(): 41 Toolkits, islice; 16 Comprehensions, Generator Expressions; 18 Performance, Lazy Evaluation with Generators; 22 Iterators, Generators; 22 Iterators, Reusable Algorithms; 41 Toolkits, Lazy Evaluation; 41 Toolkits, Case Study: Pairing Rounds; 41 Toolkits, Choosing From the Toolkits
issubclass(): 15 Context Managers, The __exit__() Arguments; 15 Context Managers, The expected Manager; 17 Metaprogramming, Making a Class Final
iter(): 22 Iterators, Iteration Comes Built In; 22 Iterators, Generators; 22 Iterators, Asking Consumes an Item; 47 Stateless in Practice, Abilities Are Not Special
__iter__(): 17 Metaprogramming, When You Still Need a Metaclass; 19 Concurrency, Sharing an Iterator Between Threads; 22 Iterators, Iteration Comes Built In; 22 Iterators, Generators; 22 Iterators, An Exhausted Generator Is Silently Empty; 22 Iterators, A Type-Checking Iterator; 22 Iterators, The Pattern That Disappeared; 47 Stateless in Practice, Abilities Are Not Special
- iterable: 22 Iterators, Iteration Comes Built In
- iterator: 19 Concurrency, Sharing an Iterator Between Threads; 22 Iterators; 22 Iterators, Iteration Comes Built In; 22 Iterators, A Type-Checking Iterator; 22 Iterators, The Pattern That Disappeared; 22 Iterators,
first() and current_item() Rebuild the List; 22 Iterators, Asking Consumes an Item; 39 Pattern Catalog, Finding a Pattern by Problem; 16 Comprehensions, The map() and filter() Equivalent; 19 Concurrency, Guidelines; 21 Design Patterns, Patterns You Have Already Seen; 21 Design Patterns, Pattern Taxonomy; 22 Iterators, Generators; 22 Iterators, An Exhausted Generator Is Silently Empty; 22 Iterators, What tee() Buffers; 22 Iterators, Delegating with yield from; 22 Iterators, Reusable Algorithms; 38 Simulation, Watching It Happen; 40 Foundations, Higher-Order Functions; 41 Toolkits, islice; 41 Toolkits, groupby; 41 Toolkits, Choosing From the Toolkits; 45 Generators, Annotating a Generator; 45 Generators, The Return Channel; 47 Stateless in Practice, A Coin Toss
- iterator protocol: 22 Iterators
itertools.chain.from_iterable(): 16 Comprehensions, Unpacking in Comprehensions
K
KeyboardInterrupt: 04 Control Flow, Errors and Exceptions; 15 Context Managers, The expected Manager
- keyword-only: 05 Functions, Positional-Only and Keyword-Only Parameters; 05 Functions, Default Parameter Values; 12 Data Classes as Types, Inheritance and the Generated
__init__(); 12 Data Classes as Types, More Data Class Tools; 14 Decorators, Decorators With Optional Parentheses; 28 Data Transfer Objects, A Hand-Rolled Messenger; 41 Toolkits, accumulate
- Kirkman's schoolgirl problem: 41 Toolkits, Groups of Any Size
KW_ONLY: 12 Data Classes as Types, More Data Class Tools
L
- lambda: 05 Functions, Lambdas; 40 Foundations, Higher-Order Functions
- disconnecting: 30 Observer, Testing the Broadcaster; 30 Observer, Setting the Responders at Construction
- late binding: 17 Metaprogramming, A Family of Generated Classes; 27 Function Objects, The Late-Binding Trap; 40 Foundations, Partial Application
- lapsed listener: 30 Observer, Lapsed Listeners; 41 Toolkits,
cache; 30 Observer, Setting the Responders at Construction; 30 Observer, The View
- Law of Demeter: 21 Design Patterns, Design Principles
- Layers: 39 Pattern Catalog, Architectural (POSA); 14 Decorators, Stacking Decorators
- lazily initialized: 07 Classes, Caching with
cached_property; 39 Pattern Catalog, Concurrency (POSA and others)
- lazy evaluation: 18 Performance, Lazy Evaluation with Generators; 41 Toolkits, Lazy Evaluation; 18 Performance, Numbers on Your Machine; 41 Toolkits; 41 Toolkits, The
itertools Toolkit
- Lazy Initialization: 39 Pattern Catalog, Other Patterns and Idioms; 25 Surrogate, What Proxy Solves; 25 Surrogate, Smart Reference
- Lazy Load: 39 Pattern Catalog, Finding a Pattern by Problem; 39 Pattern Catalog, Enterprise Application (Fowler)
__le__(): 17 Metaprogramming, The Tool in Use; 41 Toolkits, total_ordering
- Leader/Followers: 39 Pattern Catalog, Concurrency (POSA and others)
__len__(): 02 Tour, Booleans, None, and Truthiness; 20 Rethinking Objects, Prefer Composition to Inheritance; 22 Iterators, An Exhausted Generator Is Silently Empty; 25 Surrogate, Special Methods Bypass __getattr__(); 25 Surrogate, The Recursion Trap
- Liskov Substitution Principle: 20 Rethinking Objects, The Liskov Substitution Principle; 21 Design Patterns, Design Principles; 20 Rethinking Objects, Evolution; 20 Rethinking Objects, Protocols; 24 Template Method, Substitutability; 24 Template Method, What Anchors the Algorithm
- listener: 30 Observer, Easier Names; 30 Observer, Lapsed Listeners; 30 Observer, Setting the Responders at Construction; 30 Observer, The View; 41 Toolkits,
cache
Literal: 08 Static Types, Naming Types: The type Statement; 08 Static Types, Typing **kwargs with a TypedDict; 08 Static Types, Unions, Optionals, and Literals; 26 Factory, The Pythonic Factory: a Dictionary; 26 Factory, Self Registration; 26 Factory, Which Factory to Use; 41 Toolkits, partialmethod
- livelock: 19 Concurrency, Deadlock and Livelock; 19 Concurrency, Livelock
- lock: 19 Concurrency, Locks
logging.NullHandler: 20 Rethinking Objects, Null Object
LookupError: 44 Effect Management, Effects by Hand
lru_cache: 41 Toolkits, lru_cache; 14 Decorators, Decorators You Already Know; 18 Performance, Caching; 35 Flyweight, A Pool That Does Not Leak; 43 Confidence, Referential Transparency; 47 Stateless in Practice, repeat() and memoize()
__lt__(): 17 Metaprogramming, The Tool in Use; 41 Toolkits, total_ordering
M
- main guard: 06 Modules and Packages; 15 Context Managers, Combining Context Managers
- Managed Coupling: 21 Design Patterns, A Pattern Moves an Edge; 21 Design Patterns, Design Principles
map(): 16 Comprehensions, The map() and filter() Equivalent; 16 Comprehensions, Supplying the Input Iterable; 40 Foundations, Higher-Order Functions; 40 Foundations, Putting the Pieces Together; 41 Toolkits, repeat; 41 Toolkits, starmap; A Effect Tracking, Why a Native System Tracks Best; B An Effect Checker, What the Checker Resolves, and What It Cannot See
pool.map(): 19 Concurrency, Parallelism; 19 Concurrency, What a Process Pool Requires; 19 Concurrency, Raw multiprocessing; 19 Concurrency, One Executor Interface, Three Pools; 43 Confidence, Automatic Parallelism; 43 Confidence, A Family of Property Shapes
Mapping: 08 Static Types, Containers; 14 Decorators, Maintaining the Wrapped Interface; 34 Composite and Interpreter, Evaluation Is a Tree Walk; 40 Foundations, Immutability in Annotations
MappingProxyType: 03 Containers, Immutability; 03 Containers, frozendict
- mark: 11 Testing, Parametrizing Tests
- marker: 17 Metaprogramming, Making a Class Final; 17 Metaprogramming, The Four Families
- in a parameter list: 05 Functions, Positional-Only and Keyword-Only Parameters; 12 Data Classes as Types, More Data Class Tools; 28 Data Transfer Objects, A Hand-Rolled Messenger
- output lines in listings: 01 Introduction, The Examples; 02 Tour, How to Read the Examples; 06 Modules and Packages, Packages; 29 Changing the Interface, Deprecating the Old Interface; 30 Observer, Disconnecting During a Notification
- Marker Interface: 39 Pattern Catalog, Language and Implementation Idioms
__match_args__: 13 Pattern Matching, Class Patterns; 13 Pattern Matching, Keyword Patterns; 17 Metaprogramming, The Tool in Use
math.isclose(): 11 Testing, Comparing Floating-Point Values
math.prod(): 41 Toolkits, reduce
max(): 05 Functions, Positional-Only and Keyword-Only Parameters; 16 Comprehensions, Generator Expressions; 21 Design Patterns, When a Pattern Dissolves; 27 Function Objects, Strategy: Choosing the Algorithm at Runtime
- Mealy machine: 31 State Machines, Table-Driven State Machine
- Mediator: 21 Design Patterns, Coupling; 39 Pattern Catalog, Behavioral (GoF)
- memento: 36 Memento; 36 Memento, The Classic Memento; 36 Memento, Immutability; 36 Memento, Snapshots in the Wild; 39 Pattern Catalog, Finding a Pattern by Problem; 36 Memento, A Snapshot Is Not a Reference; 36 Memento, Why
Memento Is a Class; 36 Memento, Testing the Sketch; 36 Memento, Mementos That Outlive the Process; 36 Memento, A Class That Changes After the Save
- Memoization: 39 Pattern Catalog, Functional Idioms; 41 Toolkits,
cache
- memoize: 23 Singleton, When You Want a Class, Cache the Instance; 47 Stateless in Practice,
repeat() and memoize()
MemoryError: 18 Performance, Lazy Evaluation with Generators
memoryview: 03 Containers, namedtuple; 18 Performance, Memory View; 18 Performance, Choosing a Strategy
- Message Channel: 39 Pattern Catalog, Finding a Pattern by Problem; 39 Pattern Catalog, Integration and Messaging (Hohpe and Woolf)
- Message Endpoint: 39 Pattern Catalog, Finding a Pattern by Problem; 39 Pattern Catalog, Integration and Messaging (Hohpe and Woolf)
- Message Router: 39 Pattern Catalog, Finding a Pattern by Problem; 39 Pattern Catalog, Integration and Messaging (Hohpe and Woolf)
- Message Translator: 39 Pattern Catalog, Finding a Pattern by Problem; 39 Pattern Catalog, Integration and Messaging (Hohpe and Woolf)
- Messenger: 28 Data Transfer Objects, A Hand-Rolled Messenger; 28 Data Transfer Objects; 28 Data Transfer Objects,
SimpleNamespace; 39 Pattern Catalog, Finding a Pattern by Problem; 39 Pattern Catalog, Other Patterns and Idioms
- metaclasses: 17 Metaprogramming; 17 Metaprogramming, Multiple Inheritance and Metaclasses; 01 Introduction, Who This Book Is For; 17 Metaprogramming, Generating Classes with
type(); 17 Metaprogramming, The inspect Module; 23 Singleton, Singleton by Class Decorator
- metadata: A Effect Tracking, A Row Inside
Annotated
- copied by wraps: 14 Decorators,
wraps Keeps the Runtime Interface; 14 Decorators, Stacking Decorators; 41 Toolkits, wraps
- in an annotation: 08 Static Types, Aliases and Distinct Types; A Effect Tracking, A Row Inside
Annotated; A Effect Tracking, Propagate Through Callbacks; A Effect Tracking, Subtract What a Handler Discharges; A Effect Tracking, Tracking Is Not Management; B An Effect Checker, Facts About a Function
__metadata__: A Effect Tracking, A Row Inside Annotated
- metamethods: 17 Metaprogramming, Intercepting Instance Creation; 17 Metaprogramming, When You Still Need a Metaclass
- method resolution order: 07 Classes, Method Resolution Order; 09 Class Attributes, ClassVar and Inheritance; 20 Rethinking Objects, Protocols; 24 Template Method, Hooks and the Misspelled Override
- Microkernel: 39 Pattern Catalog, Architectural (POSA)
min(): 05 Functions, Positional-Only and Keyword-Only Parameters; 16 Comprehensions, Generator Expressions; 18 Performance, Trusting a Measurement; 19 Concurrency, Threads Overlap Waits, Not Computing; 27 Function Objects, Strategy: Choosing the Algorithm at Runtime; 41 Toolkits, Groups of Any Size
- mirrored machinery: 17 Metaprogramming, The Four Families
__missing__(): 17 Metaprogramming, Building Each Class on First Lookup
- mix-in: 12 Data Classes as Types, Mixing a Type into an Enum; 17 Metaprogramming, Multiple Inheritance and Metaclasses
- Mixin: 39 Pattern Catalog, Language and Implementation Idioms
- mock: 11 Testing, Stubs and Mocks; 40 Foundations; 44 Effect Management; 44 Effect Management, A Program Can Never Be Pure; 46 Stateless, Swapping the Implementation
- model: 30 Observer, A Visual Example
- Model-View-Controller: 30 Observer; 39 Pattern Catalog, Finding a Pattern by Problem; 39 Pattern Catalog, Architectural (POSA)
- module: 06 Modules and Packages; 06 Modules and Packages, File Names
__module__: 14 Decorators, wraps Keeps the Runtime Interface; 17 Metaprogramming, Pickling Generated Classes; 17 Metaprogramming, Self-Registration of Subclasses; 17 Metaprogramming, Attributes on a Function; 17 Metaprogramming, Building display_object(); 17 Metaprogramming, The Tool in Use; 26 Factory, Hazards of Self Registration; B An Effect Checker, Effect Names and the Table
ModuleNotFoundError: 06 Modules and Packages, Imports Within a Package; 06 Modules and Packages, File Names; 06 Modules and Packages, PYTHONPATH; 11 Testing, Test-Driven Development (TDD); 17 Metaprogramming, Building display_object()
- monad: 39 Pattern Catalog, Functional Idioms; 42 Error Handling, Composing With bind; 47 Stateless in Practice, 3. Handlers cannot capture the continuation
- Monitor Object: 39 Pattern Catalog, Concurrency (POSA and others)
- Moore machine: 31 State Machines, Each State Decides
__mro__: 07 Classes, Method Resolution Order; 17 Metaprogramming, Building display_object(); 24 Template Method, Hooks and the Misspelled Override; 27 Function Objects, An Event Bus: Handlers Keyed by Type
mul(): 41 Toolkits, accumulate
__mul__(): 34 Composite and Interpreter, Interpreter; 34 Composite and Interpreter, Operators That Build Nodes
- Multiple Dispatching: 32 Multiple Dispatching; 33 Visitor, One Dispatch Is Enough
multiprocessing: 19 Concurrency, Raw multiprocessing; 19 Concurrency, Why Python Has a GIL; 19 Concurrency, Coordinating Threads with Queues; 19 Concurrency, Guidelines
multiprocessing.Manager: 19 Concurrency, Raw multiprocessing
- Multiton: 35 Flyweight, Interning in the Constructor; 39 Pattern Catalog, Finding a Pattern by Problem; 39 Pattern Catalog, Other Patterns and Idioms
- mutable: 02 Tour, Variables and References
N
- name mangling: 11 Testing, White-Box and Black-Box Tests
namedtuple: 03 Containers, namedtuple; 12 Data Classes as Types, A NamedTuple Cannot Validate Itself; 28 Data Transfer Objects, NamedTuple; 03 Containers, Specialized Containers; 03 Containers, Choosing a Container; 13 Pattern Matching, Class Patterns; 18 Performance, When Slots Does Not Fit; 28 Data Transfer Objects, @dataclass; 28 Data Transfer Objects, Returning Multiple Values; 28 Data Transfer Objects, Which Should You Use?
- as a tuple: 28 Data Transfer Objects, A NamedTuple Is Still a Tuple; 28 Data Transfer Objects, Subclassing
tuple Directly
NameError: 02 Tour, Indentation and Blocks; 06 Modules and Packages, Packages; 06 Modules and Packages, Circular Imports; 16 Comprehensions, Scope and the Walrus Operator; 16 Comprehensions, Nested Comprehensions; 17 Metaprogramming, Reading Annotations Before Their Names Exist; 40 Foundations, Closures; 42 Error Handling, Turning Exceptions into Results
- from an annotation: 17 Metaprogramming, Sorting Members into Attributes and Methods; 17 Metaprogramming, Reading Annotations Before Their Names Exist; 23 Singleton, Nothing Keeps the Class Private
- namespace: 06 Modules and Packages; 06 Modules and Packages, The Module Namespace; 06 Modules and Packages, Importing Names with
from and as; 06 Modules and Packages, Packages; 17 Metaprogramming, Generating Classes with exec()
- against name collisions: 20 Rethinking Objects, OOP Is Useful, Sometimes; 23 Singleton, Which Should You Use?; 44 Effect Management, Effects Are the Next Barrier
- of a class being built: 17 Metaprogramming, Generating Classes with
type(); 17 Metaprogramming, A Family of Generated Classes; 17 Metaprogramming, Generating Classes with exec(); 17 Metaprogramming, __init__() versus __new__() in a Metaclass; 17 Metaprogramming, When You Still Need a Metaclass; 17 Metaprogramming, Which Hook for Which Job; 23 Singleton, Singleton by Class Decorator
- namespace package: 06 Modules and Packages, Packages
- narrows: 08 Static Types, Narrowing; 08 Static Types, Type Narrowing; 09 Class Attributes, A Base Class Declares, a Subclass Supplies; 16 Comprehensions, The
map() and filter() Equivalent; 17 Metaprogramming, Building display_object(); 35 Flyweight, Typing the Symbol Set; 42 Error Handling, A Result Type
Never: 08 Static Types, Basic Types; 46 Stateless, The Effect Type
- in an Effect's error channel: 46 Stateless, The Effect Type; 46 Stateless, Turning an Error Into a Value; 46 Stateless, Emptying the Channels; 47 Stateless in Practice, Failing from Inside an Effect; 47 Stateless in Practice, Catching the Whole Channel; 47 Stateless in Practice, 2. The type checker decides what survives handling
__new__(): 17 Metaprogramming, __init__() versus __new__() in a Metaclass; 17 Metaprogramming, Writing a Metaclass; 17 Metaprogramming, Intercepting Instance Creation; 17 Metaprogramming, Which Hook for Which Job; 23 Singleton, Singleton by Class Decorator; B An Effect Checker, What the Checker Resolves, and What It Cannot See
- for a Singleton: 23 Singleton, One Instance in a Class Variable; 23 Singleton, Singleton by Class Decorator
- for interning: 35 Flyweight, Interning in the Constructor; 35 Flyweight, A Known Set: Enum; 35 Flyweight, Choosing a Flyweight and Its Pool
- in an immutable subclass: 12 Data Classes as Types, A
NamedTuple Cannot Validate Itself; 28 Data Transfer Objects, Subclassing tuple Directly
NewType: 08 Static Types, Naming Types: The type Statement; 08 Static Types, Aliases and Distinct Types; 20 Rethinking Objects, Protocols; 36 Memento, Why Memento Is a Class; 45 Generators, Annotating a Generator
__next__(): 19 Concurrency, Sharing an Iterator Between Threads; 19 Concurrency, Guidelines; 22 Iterators, Iteration Comes Built In; 22 Iterators, Generators; 22 Iterators, A Type-Checking Iterator; 22 Iterators, The Pattern That Disappeared; 22 Iterators, first() and current_item() Rebuild the List; 22 Iterators, Asking Consumes an Item
- nominal: 20 Rethinking Objects, Protocols
- non-data descriptor: 17 Metaprogramming, A Descriptor That Learns Its Name
nonlocal: 05 Functions, Names Inside a Function; 14 Decorators, A Class-Form Decorator with State; 40 Foundations, Closures
__notes__: 42 Error Handling, Attaching Context to an Exception; 43 Confidence, Shrinking a Failure
notify(): 30 Observer, Why notify() Copies the List; 30 Observer, The Classic Observer; 30 Observer, Push or Pull; 30 Observer, Easier Names; 30 Observer, The Pythonic Observer
NotImplemented: 32 Multiple Dispatching, Operators Dispatch Twice; 34 Composite and Interpreter, Operators That Build Nodes
NotImplementedError: 24 Template Method, Hooks and the Misspelled Override; 26 Factory, Self Registration; 27 Function Objects, Command: Choosing the Operation at Runtime; 32 Multiple Dispatching, The singledispatchmethod Trap; 32 Multiple Dispatching, Operators Dispatch Twice; 33 Visitor, The Pythonic Visitor: singledispatch; 37 Pattern Refactoring, One singledispatch Function per Operation
NotRequired: 08 Static Types, Typing **kwargs with a TypedDict; 08 Static Types, Dictionary and Record Shapes
now: 02 Tour, Variables and References; 11 Testing, The Clock; 13 Pattern Matching, A Bare Name Captures, a Dotted Name Compares; 19 Concurrency, Context That Follows the Call Chain; 22 Iterators, The Body Waits for the First next(); 47 Stateless in Practice, A Clock; 47 Stateless in Practice, A Clock That Crosses Midnight; B An Effect Checker, Effect Names and the Table
nt: B An Effect Checker, Effect Names and the Table
- Null Object: 20 Rethinking Objects, Null Object; 21 Design Patterns, Pattern Taxonomy; 38 Simulation, Rooms, Robots, and the Item Factory; 38 Simulation, Watching the Robot; 39 Pattern Catalog, Finding a Pattern by Problem; 39 Pattern Catalog, Other Patterns and Idioms
nullcontext: 15 Context Managers, The contextlib Toolkit; 15 Context Managers, Choosing a Form
O
- object adapter: 29 Changing the Interface, Three Places for the Adaptation
- Object Pool: 15 Context Managers, An Object Pool; 19 Concurrency, Coordinating Threads with Queues; 39 Pattern Catalog, Finding a Pattern by Problem; 39 Pattern Catalog, Other Patterns and Idioms
object.__setattr__(): 12 Data Classes as Types, Normalizing a Frozen Field; 25 Surrogate, Forwarding Writes; 35 Flyweight, Interning in the Constructor
- observer: 30 Observer; 30 Observer, The Classic Observer; 30 Observer, Easier Names; 30 Observer, The Pythonic Observer; 30 Observer, Setting the Responders at Construction; 30 Observer, Observer and I/O; 30 Observer, Deciding What Matters; 39 Pattern Catalog, Finding a Pattern by Problem; 19 Concurrency, Escaping to a Thread; 21 Design Patterns, A Pattern Moves an Edge; 30 Observer, Push or Pull; 30 Observer, Why
notify() Copies the List
- as an event bus: 27 Function Objects, A Tagged Bus: Handlers That Name Their Event
- in a simulation: 38 Simulation, Watching the Pack
- its coupling: 21 Design Patterns, Coupling; 21 Design Patterns, A Pattern Moves an Edge
- lapsed listener leak: 41 Toolkits,
cache
open(): 04 Control Flow, Ask Forgiveness, Not Permission; 10 Cleanup, The Rule; 11 Testing, Filesystem and Environment; 29 Changing the Interface, Adapter in Python; 47 Stateless in Practice, 1. Nothing stops an undeclared Effect; A Effect Tracking, Decide What Untracked Code Performs; B An Effect Checker, Effect Names and the Table
operator.attrgetter(): 05 Functions, Lambdas
operator.itemgetter(): 05 Functions, Lambdas
operator.or_(): 41 Toolkits, reduce
or: 02 Tour, Booleans, None, and Truthiness; 13 Pattern Matching, Alternatives and Capture; 13 Pattern Matching, When Not to Match; 34 Composite and Interpreter, Operators That Build Nodes
- oracle: 43 Confidence, A Family of Property Shapes
- originator: 36 Memento; 36 Memento, The Classic Memento; 36 Memento, Immutability
- Orthogonality: 21 Design Patterns, Design Principles
os.path.join: B An Effect Checker, Effect Names and the Table; B An Effect Checker, From a Call to a Name
os.remove: B An Effect Checker, Effect Names and the Table; B An Effect Checker, From a Call to a Name
OSError: 16 Comprehensions, The Gap Between Creation and Consumption; 17 Metaprogramming, Pickling Generated Classes; B An Effect Checker, Facts About a Function
OverflowError: 20 Rethinking Objects, The Liskov Substitution Principle
@overload: 08 Static Types, Typing Decorators and Directives; 14 Decorators, Decorators With Optional Parentheses; 18 Performance, A Decorator for the Default; 20 Rethinking Objects, What Is Polymorphism?; 29 Changing the Interface, Deprecating the Old Interface; 33 Visitor, Two Departures from the Classic Shape
@override: 07 Classes, Marking Overrides with @override; 07 Classes, Inheritance; 08 Static Types, Typing Decorators and Directives; 17 Metaprogramming, Attributes on a Function; 17 Metaprogramming, The Four Families; 20 Rethinking Objects, The Liskov Substitution Principle; 24 Template Method, Hooks and the Misspelled Override; 24 Template Method, Substitutability; see also __override__
- and substitutability: 20 Rethinking Objects, The Liskov Substitution Principle; 24 Template Method, Substitutability
- catching a misspelled hook: 24 Template Method, Hooks and the Misspelled Override
__override__: 07 Classes, Marking Overrides with @override; 17 Metaprogramming, Attributes on a Function; 17 Metaprogramming, The Four Families
P
- packages: 06 Modules and Packages, Packages; 06 Modules and Packages, Nested Packages; 06 Modules and Packages, File Names
Pair: 08 Static Types, Type Parameter Defaults; 20 Rethinking Objects, Protocols Generalize, Composition Adapts; 29 Changing the Interface, Adapter in Python
pairwise: 41 Toolkits, pairwise; 41 Toolkits, Choosing From the Toolkits
- panics: 42 Error Handling, Which Failures Get a Result
- parameter: 05 Functions
- parameter specification: 14 Decorators,
**P and R Keep the Static Interface
- parametric polymorphism: 20 Rethinking Objects, What Is Polymorphism?
partial(): 41 Toolkits, partial; 27 Function Objects, The Late-Binding Trap; 27 Function Objects, Strategy: Choosing the Algorithm at Runtime; 27 Function Objects, Choosing the Lightest Callable; 40 Foundations, Partial Application; 40 Foundations, Leaving a Gap with Placeholder; 40 Foundations, Putting the Pieces Together; 41 Toolkits, partialmethod; A Effect Tracking, Propagate Through Callbacks
- Partial Application: 39 Pattern Catalog, Functional Idioms; 40 Foundations, Partial Application; 41 Toolkits,
partial
partialmethod: 41 Toolkits, partialmethod
Path: 11 Testing, Filesystem and Environment; 15 Context Managers, The contextlib Toolkit; 16 Comprehensions, Supplying the Input Iterable; 16 Comprehensions, The Gap Between Creation and Consumption; 29 Changing the Interface, Adapter in Python; 29 Changing the Interface, Deprecating the Old Interface; 34 Composite and Interpreter, A Composite of Data Classes
pathlib: 04 Control Flow, Context Managers; 29 Changing the Interface, Adapter in Python; 34 Composite and Interpreter, A Composite of Data Classes; B An Effect Checker, From a Call to a Name; B An Effect Checker, What the Checker Resolves, and What It Cannot See
pathlib.Path.read_text: B An Effect Checker, Effect Names and the Table; B An Effect Checker, From a Call to a Name
pathlib.Path.with_suffix.write_text: B An Effect Checker, What the Checker Resolves, and What It Cannot See
- Pattern-Oriented Software Architecture: 39 Pattern Catalog
peak: 15 Context Managers, An Empty Pool Blocks the Borrower; 18 Performance, Numbers on Your Machine; 18 Performance, Lazy Evaluation with Generators; 19 Concurrency, Overlapping the Waits; 19 Concurrency, Semaphores; 22 Iterators, What tee() Buffers
PermissionError: 25 Surrogate, Protection Proxy; 46 Stateless, Built-in Dependencies; 47 Stateless in Practice, The Toolkit
permutations: 41 Toolkits, permutations and combinations
pickle: 12 Data Classes as Types, copy() and deepcopy() Skip the Constructor; 17 Metaprogramming, Pickling Generated Classes; 25 Surrogate, The Recursion Trap; 26 Factory, Prototype; 29 Changing the Interface, Adapter in Python; 36 Memento, Mementos That Outlive the Process; 36 Memento, A Class That Changes After the Save; 36 Memento, A Deleted Field Leaves a Ghost
pickle.dumps(): 17 Metaprogramming, Pickling Generated Classes; 29 Changing the Interface, Adapter in Python; 36 Memento, Mementos That Outlive the Process; 36 Memento, A Class That Changes After the Save; 36 Memento, A Deleted Field Leaves a Ghost
pickle.loads(): 29 Changing the Interface, Adapter in Python; 36 Memento, Mementos That Outlive the Process; 36 Memento, A Class That Changes After the Save; 36 Memento, A Deleted Field Leaves a Ghost
- pickling: 17 Metaprogramming, Pickling Generated Classes; 19 Concurrency, What a Process Pool Requires; 19 Concurrency, Coordinating Threads with Queues; 19 Concurrency, One Task, Many Backends; 26 Factory, Prototype; 43 Confidence, Automatic Parallelism
- Pipes and Filters: 39 Pattern Catalog, Architectural (POSA)
Placeholder: 40 Foundations, Leaving a Gap with Placeholder; 27 Function Objects, Strategy: Choosing the Algorithm at Runtime; 41 Toolkits, partial
- pluggable adapter: 29 Changing the Interface, Three Places for the Adaptation
- Plugin: 39 Pattern Catalog, Enterprise Application (Fowler); 06 Modules and Packages, Limits of
lazy; 23 Singleton; 26 Factory, Hazards of Self Registration; 34 Composite and Interpreter, The Classic Composite; 34 Composite and Interpreter, A Composite of Data Classes; 40 Foundations, Functions as First-Class Objects
- Point-to-Point Channel: 39 Pattern Catalog, Finding a Pattern by Problem; 39 Pattern Catalog, Integration and Messaging (Hohpe and Woolf)
- Pointer to Implementation: 39 Pattern Catalog, Language and Implementation Idioms
pop(): 03 Containers, Dictionaries; 03 Containers, deque; 04 Control Flow, Loops; 10 Cleanup, Watching Objects Without Holding Them; 18 Performance, Heap; 36 Memento, The Caretaker: a Generic History
- positional-only: 05 Functions, Positional-Only and Keyword-Only Parameters; 15 Context Managers, The
expect() Function; 27 Function Objects, Strategy: Choosing the Algorithm at Runtime; 29 Changing the Interface, What an Override May Change; 40 Foundations, Leaving a Gap with Placeholder
posix: B An Effect Checker, Effect Names and the Table
- premature optimization: 18 Performance, Is It Too Slow?
__prepare__(): 17 Metaprogramming, When You Still Need a Metaclass; 17 Metaprogramming, Which Hook for Which Job
- Presentation-Abstraction-Control: 39 Pattern Catalog, Architectural (POSA)
- principle of least astonishment: 21 Design Patterns, Design Principles
PriorityQueue: 18 Performance, Heap; 19 Concurrency, Coordinating Threads with Queues
- Proactor: 39 Pattern Catalog, Concurrency (POSA and others)
- process: 19 Concurrency
ProcessPoolExecutor: 19 Concurrency, Parallelism; 19 Concurrency, Raw multiprocessing; 19 Concurrency, Measuring the Speedup; 19 Concurrency, One Executor Interface, Three Pools; 19 Concurrency, One await, Any Backend; 19 Concurrency, Guidelines; 43 Confidence, Automatic Parallelism; 47 Stateless in Practice, Running Effects in Parallel
- Producer-Consumer: 39 Pattern Catalog, Finding a Pattern by Problem; 39 Pattern Catalog, Concurrency (POSA and others)
product(): 41 Toolkits, product; 32 Multiple Dispatching; 41 Toolkits, permutations and combinations
profile: 18 Performance, The Sampling Profiler; 45 Generators, Composing Is Not Interpreting
- profiler: 18 Performance, Profilers; 18 Performance, The Sampling Profiler; 18 Performance, Reading a
cProfile Report; 18 Performance, Measuring One Function with sys.monitoring; 18 Performance, Benchmark Alternatives with timeit; 18 Performance, Choosing a Strategy
profiling: 18 Performance, The Sampling Profiler
profiling.sampling: 18 Performance, The Sampling Profiler
profiling.tracing: 18 Performance, The Sampling Profiler
@property: 07 Classes, Properties; 07 Classes, Adding a Setter; 07 Classes, Caching with cached_property; 09 Class Attributes, Two Dictionaries, One Lookup; 12 Data Classes as Types, A Class Is Not a Type; 14 Decorators, The Decorator Pattern; 14 Decorators, Decorators You Already Know; 24 Template Method, Hooks and the Misspelled Override; 30 Observer, Decorated Responders; see also setter, cached_property, descriptor
- property() as a class: 14 Decorators, Decorators as Classes; 17 Metaprogramming, A Descriptor That Validates; 30 Observer, Decorated Responders
- with a setter: 07 Classes, Adding a Setter
- property-based: 11 Testing, Property-Based Testing; 43 Confidence, Property-Based Testing; 43 Confidence, A Confidence Spectrum
- property-based testing: 11 Testing, Property-Based Testing; 43 Confidence, A Confidence Spectrum; 43 Confidence, Property-Based Testing
- protection proxy: 25 Surrogate, What Proxy Solves; 25 Surrogate, Protection Proxy; 25 Surrogate, Smart Reference; 25 Surrogate, A Surrogate Is Not Its Implementation
Protocol: 08 Static Types, Structural Typing with Protocols; 20 Rethinking Objects, Protocols Generalize, Composition Adapts; 20 Rethinking Objects, Protocols; 26 Factory, Explicit Registration with a Protocol; see also structural typing
- checked at runtime: 08 Static Types, Structural Typing; 25 Surrogate, A Surrogate Is Not Its Implementation; 46 Stateless, An Interface Instead of a Base Class
- declaring __call__(): 27 Function Objects, A Callable Object as a Command
- versus an ABC: 20 Rethinking Objects, What Is Polymorphism?
- Prototype: 26 Factory, Prototype; 21 Design Patterns, Pattern Taxonomy; 26 Factory; 26 Factory, The Pythonic Factory: a Dictionary; 26 Factory, Builder; 39 Pattern Catalog, Finding a Pattern by Problem; 39 Pattern Catalog, Creational (GoF); 39 Pattern Catalog, Patterns Python Absorbed
- Proxy: 25 Surrogate, Proxy; 25 Surrogate, What Proxy Solves; 25 Surrogate; 25 Surrogate, Explicit Forwarding; 25 Surrogate, One Surrogate, Two Intents; 29 Changing the Interface, Distinguishing the Wrappers; 39 Pattern Catalog, Finding a Pattern by Problem
- and Adapter: 25 Surrogate, What the Implementation Supplies; 29 Changing the Interface; 29 Changing the Interface, Adapter; 29 Changing the Interface, Distinguishing the Wrappers
- and State: 21 Design Patterns, Pattern Taxonomy; 25 Surrogate; 25 Surrogate, State; 25 Surrogate, One Surrogate, Two Intents; 39 Pattern Catalog, Other Patterns and Idioms
- protection: 25 Surrogate, Protection Proxy
- virtual: 25 Surrogate, Virtual Proxy
- Publish-Subscribe Channel: 39 Pattern Catalog, Finding a Pattern by Problem; 39 Pattern Catalog, Integration and Messaging (Hohpe and Woolf)
- pure function: 40 Foundations, Pure Functions
- and parallelism: 18 Performance, Concurrency; 43 Confidence, Automatic Parallelism; 44 Effect Management, A Program Can Never Be Pure
- caching: 18 Performance, Caching; 18 Performance, Choosing a Strategy; 41 Toolkits; 41 Toolkits,
cache; 41 Toolkits, Choosing From the Toolkits; 43 Confidence, Referential Transparency
- needing no test setup: 40 Foundations; 44 Effect Management, A Program Can Never Be Pure
PYTHONPATH: 06 Modules and Packages, PYTHONPATH; 06 Modules and Packages; 17 Metaprogramming, Building display_object()
Q
- qualify: 06 Modules and Packages; 06 Modules and Packages, Packages
__qualname__: 14 Decorators, wraps Keeps the Runtime Interface; 17 Metaprogramming, Self-Registration of Subclasses; 26 Factory, Hazards of Self Registration; 33 Visitor, The Classic Visitor
Queue: 03 Containers, deque; 15 Context Managers, An Object Pool; 15 Context Managers, An Empty Pool Blocks the Borrower; 19 Concurrency, Raw multiprocessing; 19 Concurrency, Coordinating Threads with Queues; 19 Concurrency, Guidelines
queue.Empty: 15 Context Managers, What the Skeleton Leaves Out
R
__radd__(): 32 Multiple Dispatching; 32 Multiple Dispatching, Operators Dispatch Twice; 32 Multiple Dispatching, Turning One Unknown Type Into a Second Dispatch; 34 Composite and Interpreter, Interpreter; 34 Composite and Interpreter, Operators That Build Nodes
random: 11 Testing, Random Numbers; 43 Confidence, Shrinking a Failure; 47 Stateless in Practice, A Coin Toss
random.randint(): 11 Testing, Random Numbers; 43 Confidence, Property-Based Testing
random.Random: 11 Testing, Random Numbers; 38 Simulation, The Model; 38 Simulation, Testing a Random Process; 41 Toolkits, Groups of Any Size; 41 Toolkits, history Is Mutable State; 47 Stateless in Practice, A Source Named in the Type
re.escape(): 11 Testing, Testing for Exceptions
re.search(): 11 Testing, Testing for Exceptions
- Reactor: 39 Pattern Catalog, Finding a Pattern by Problem; 39 Pattern Catalog, Concurrency (POSA and others)
- Read-Write Lock: 39 Pattern Catalog, Concurrency (POSA and others)
readline(): 19 Concurrency, A Real Socket; 44 Effect Management, Native Effect Management
- record: 18 Performance, A Decorator for the Default
- recursion: 41 Toolkits, Recursion
- in attribute forwarding: 25 Surrogate, The Recursion Trap; 25 Surrogate, Forwarding with
__getattr__(); 29 Changing the Interface, Adapter in Python
- over trees and unions: 13 Pattern Matching, Patterns Nest; 34 Composite and Interpreter, A Composite of Data Classes; 34 Composite and Interpreter, Simplification Rewrites the Tree; 34 Composite and Interpreter, A Template Is a Tree; 38 Simulation, Rooms, Robots, and the Item Factory
RecursionError: 07 Classes, Adding a Setter; 17 Metaprogramming, A Descriptor That Learns Its Name; 25 Surrogate, The Recursion Trap; 29 Changing the Interface, Adapter in Python; 30 Observer, Re-entrant Notification; 41 Toolkits, Recursion
- recursive: 34 Composite and Interpreter, A Composite of Data Classes; 41 Toolkits, Recursion
- Fibonacci: 18 Performance, Caching; 41 Toolkits,
cache; 44 Effect Management
- tree walkers: 34 Composite and Interpreter; 34 Composite and Interpreter, A Composite of Data Classes; 34 Composite and Interpreter, The Nodes and the
Operators Base; 34 Composite and Interpreter, Evaluation Is a Tree Walk; 34 Composite and Interpreter, Simplification Rewrites the Tree; 34 Composite and Interpreter, A Template Is a Tree
- recursive case: 41 Toolkits, Recursion
reduce(): 41 Toolkits, reduce; 41 Toolkits, The functools Toolkit; 41 Toolkits, accumulate
ref(): 10 Cleanup, The self.close Trap; 10 Cleanup, A Slotted Class Needs __weakref__; 17 Metaprogramming, Reading Annotations Before Their Names Exist; 18 Performance, When Slots Does Not Fit; 30 Observer, Lapsed Listeners
- Refactoring: 37 Pattern Refactoring; 01 Introduction, How the Book Fits Together; 09 Class Attributes,
type(self) Forks the Counter; 21 Design Patterns, Design Principles; 26 Factory, Self Registration; 27 Function Objects, A Tagged Bus: Handlers That Name Their Event; 31 State Machines, A Vending Machine; 33 Visitor, Where Visitor Still Fits
- reference counting: 19 Concurrency, Why Python Has a GIL; 10 Cleanup, The
self.close Trap; 10 Cleanup, Watching Objects Without Holding Them; 19 Concurrency, Free Threading; 30 Observer, Lapsed Listeners; 35 Flyweight, A Pool That Does Not Leak
ReferenceError: 25 Surrogate, What Proxy Solves
- referentially transparent: 43 Confidence, Referential Transparency; 44 Effect Management, Are Exceptions Impure?
- reflected: 32 Multiple Dispatching, Operators Dispatch Twice; 34 Composite and Interpreter, Operators That Build Nodes
- Reflection: 39 Pattern Catalog, Architectural (POSA); 31 State Machines, A Vending Machine
- Reflexivity: 21 Design Patterns, Design Principles
- Registry: 39 Pattern Catalog, Finding a Pattern by Problem; 39 Pattern Catalog, Enterprise Application (Fowler)
- relative import: 06 Modules and Packages, Imports Within a Package
- remote proxy: 25 Surrogate, What Proxy Solves
replace(): 12 Data Classes as Types, The General Form of replace(); 02 Tour, Common String Operations; 12 Data Classes as Types, Data Classes; 20 Rethinking Objects, Prefer Composition to Inheritance; 26 Factory, Builder; 26 Factory, Which Factory to Use
copy.replace(): 12 Data Classes as Types, Data Classes; 12 Data Classes as Types, The General Form of replace(); 12 Data Classes as Types, Defining __replace__(); 26 Factory, Prototype; 26 Factory, Builder; 36 Memento, Restoring Part of a State; 39 Pattern Catalog, Patterns Python Absorbed; 40 Foundations, Immutability
dataclasses.replace(): 12 Data Classes as Types, The General Form of replace(); 12 Data Classes as Types, Defining __replace__(); 36 Memento, Immutability; 36 Memento, Restoring Part of a State
__replace__(): 12 Data Classes as Types, Defining __replace__(); 12 Data Classes as Types, Data Classes; 12 Data Classes as Types, The General Form of replace(); 17 Metaprogramming, The Tool in Use; 26 Factory, Builder; 28 Data Transfer Objects, NamedTuple; 36 Memento, Restoring Part of a State
Report: 21 Design Patterns, The Reach of a Change; 29 Changing the Interface, Deprecating the Old Interface; B An Effect Checker, The Check; B An Effect Checker, The Checker Checks Itself
- Repository: 39 Pattern Catalog, Finding a Pattern by Problem; 39 Pattern Catalog, Enterprise Application (Fowler); 01 Introduction, The Examples; 01 Introduction, The Exercises; 01 Introduction, Copyright; 18 Performance, Converting a Slow Function to Rust
repr(): 02 Tour, Booleans, None, and Truthiness; 02 Tour, Common String Operations; 08 Static Types, Narrowing; 12 Data Classes as Types, Mixing a Type into an Enum; 17 Metaprogramming, Sorting Members into Attributes and Methods; 17 Metaprogramming, The Tool in Use; 28 Data Transfer Objects, SimpleNamespace; 35 Flyweight, A Known Set: Enum; 36 Memento, A Deleted Field Leaves a Ghost; 40 Foundations, Higher-Order Functions
!r: 02 Tour, f-Strings; 07 Classes, String Representation; 15 Context Managers, The __exit__() Arguments
__repr__(): 07 Classes, Marking Overrides with @override; 07 Classes, String Representation; 12 Data Classes as Types, Data Classes; 12 Data Classes as Types, A: Annotations Only; 14 Decorators, A Limitation: Methods Need a Descriptor; 17 Metaprogramming, The Tool in Use; 30 Observer, Decorated Responders; 35 Flyweight, Interning in the Constructor
- generated by a data class: 12 Data Classes as Types, Data Classes; 18 Performance, Slots; 28 Data Transfer Objects, A Hand-Rolled Messenger
ResourceWarning: 10 Cleanup, The Rule
- retry: 39 Pattern Catalog, Finding a Pattern by Problem; 39 Pattern Catalog, Distributed and Cloud; 47 Stateless in Practice, What Retry Cannot Judge; 47 Stateless in Practice, What Retry Does to the Signature; 32 Multiple Dispatching; 44 Effect Management, Tracking and Management; 46 Stateless, An Effect Runs Once; 47 Stateless in Practice; 47 Stateless in Practice, The Success Path; 47 Stateless in Practice, Dependencies That Need Dependencies; 47 Stateless in Practice, Adding Behavior to an Existing Effect; 47 Stateless in Practice,
retry() and a Flaky Database; 47 Stateless in Practice, 5. Much of a mature Effect system is missing
reveal_type(): 08 Static Types, Catching Mistakes; 08 Static Types, Type Parameter Defaults; 08 Static Types, Typing Decorators and Directives; 46 Stateless, Supplying the Dependency; 47 Stateless in Practice, What Retry Does to the Signature; 47 Stateless in Practice, 2. The type checker decides what survives handling
__rmul__(): 32 Multiple Dispatching, Operators Dispatch Twice; 34 Composite and Interpreter, Interpreter; 34 Composite and Interpreter, Operators That Build Nodes
rng: 11 Testing, Random Numbers; 11 Testing, The Clock; 19 Concurrency, Context That Follows the Call Chain; 38 Simulation, The Model; 41 Toolkits, Groups of Any Size
round(): 02 Tour, Numbers and Arithmetic; 07 Classes, Static and Class Methods; 13 Pattern Matching, Exhaustive Matching; 13 Pattern Matching, The Inheritance Version; 13 Pattern Matching, The match Version; 20 Rethinking Objects, Abstract Base Classes; 20 Rethinking Objects, Pattern Matching on a Union
__rsub__(): 32 Multiple Dispatching, Operators Dispatch Twice
__rtruediv__(): 32 Multiple Dispatching, Operators Dispatch Twice
ruff: 01 Introduction, The Examples; 08 Static Types; 12 Data Classes as Types, Defaults Built Fresh, Not Shared; 13 Pattern Matching, A Bare Name Captures, a Dotted Name Compares; 22 Iterators, Reusable Algorithms; 46 Stateless, Effects Propagate, and the Type Checker Verifies It; A Effect Tracking, Find a Place to Run
- run-time type identification: 37 Pattern Refactoring, The First Cut: Checking Every Type
@runtime_checkable: 08 Static Types, Structural Typing with Protocols; 08 Static Types, Structural Typing; 25 Surrogate, What the Implementation Supplies; 25 Surrogate, A Surrogate Is Not Its Implementation; 46 Stateless, An Interface Instead of a Base Class; 47 Stateless in Practice, Switching Implementations Mid-Run; 47 Stateless in Practice, Composing a Program; 47 Stateless in Practice, Supplying a Whole Cast
RuntimeWarning: 19 Concurrency, async def, await, and the Event Loop; 46 Stateless, Where to Call run()
S
@safe: 02 Tour, t-Strings; 10 Cleanup, The self.close Trap; 42 Error Handling, Turning Exceptions into Results; 42 Error Handling, Matching on the Error; 42 Error Handling, The returns Library; 44 Effect Management, Return a Result Type; 44 Effect Management, Combine the First and Third; 46 Stateless, Declaring a Failure with @throws
- scenario: 47 Stateless in Practice, Composing a Program; 47 Stateless in Practice,
repeat() and memoize()
- schema migration: 36 Memento, Schema Migrations and Safer Formats
select(): 30 Observer, The Model; 30 Observer, Testing the Model; 30 Observer, The View
Self: 08 Static Types, The Self Return Type; 08 Static Types, Self and Forward References; 12 Data Classes as Types, Defining __replace__(); 15 Context Managers, The Protocol; 26 Factory, Builder; 28 Data Transfer Objects, Subclassing tuple Directly; 38 Simulation, The Rat and the Blackboard; 47 Stateless in Practice, Abilities Are Not Special
self.__dict__: 12 Data Classes as Types, Inheritance and the Generated __init__(); 23 Singleton, Borg: Singleton by Inheritance; 28 Data Transfer Objects, A Hand-Rolled Messenger; 30 Observer, Notifying Without a Base Class; 30 Observer, Decorated Responders
self.close: 10 Cleanup, The self.close Trap; 10 Cleanup, An Explicit close() and a with Block; 10 Cleanup, weakref.finalize() as a Backstop
__self__: 10 Cleanup, The self.close Trap; 27 Function Objects, A Bound Method as a Command; 29 Changing the Interface, Adapter in Python
- semaphore: 19 Concurrency, Semaphores; 15 Context Managers, The Async Protocol; 19 Concurrency, Overlapping the Waits
- sentinel: 05 Functions, Sentinel Values; 15 Context Managers, The
expected Manager; 17 Metaprogramming, Building display_object(); 22 Iterators, Asking Consumes an Item; 23 Singleton, Lazy Creation; 32 Multiple Dispatching, Operators Dispatch Twice; 41 Toolkits, zip_longest
Sequence: 08 Static Types, Variance; 08 Static Types, Containers; 17 Metaprogramming, Building display_object(); 22 Iterators, An Exhausted Generator Is Silently Empty; 31 State Machines, A Vending Machine; 40 Foundations, Immutability in Annotations; 40 Foundations, Putting the Pieces Together
- Service Discovery: 39 Pattern Catalog, Distributed and Cloud
- Service Layer: 39 Pattern Catalog, Finding a Pattern by Problem; 39 Pattern Catalog, Enterprise Application (Fowler)
- Service Locator: 39 Pattern Catalog, Finding a Pattern by Problem; 39 Pattern Catalog, Dependency Supply; 46 Stateless, Dependency Injection
__set__(): 17 Metaprogramming, Learning a Name with __set_name__(); 17 Metaprogramming, A Descriptor That Learns Its Name; 17 Metaprogramming, A Descriptor That Validates
__set_name__(): 17 Metaprogramming, Learning a Name with __set_name__(); 17 Metaprogramming; 17 Metaprogramming, A Descriptor That Learns Its Name; 17 Metaprogramming, A Descriptor That Validates; 17 Metaprogramming, When You Still Need a Metaclass; 17 Metaprogramming, Which Hook for Which Job; 23 Singleton, Singleton by Class Decorator
setattr(): 09 Class Attributes, Two Dictionaries, One Lookup; 12 Data Classes as Types, Immutability; 17 Metaprogramming, Writing a Metaclass; 17 Metaprogramming, __init__() versus __new__() in a Metaclass; 20 Rethinking Objects, The Immutability Solution; 40 Foundations, Immutability
__setattr__(): 23 Singleton, Lazy Creation; 25 Surrogate, Forwarding Writes; 28 Data Transfer Objects, A Hand-Rolled Messenger; 30 Observer, Notifying Without a Base Class; 30 Observer, Deciding What Matters; 35 Flyweight, Interning in the Constructor
- on a frozen data class: 12 Data Classes as Types, Normalizing a Frozen Field; 12 Data Classes as Types, Frozen and Plain Data Classes Do Not Mix; 36 Memento, A Class That Changes After the Save
__setitem__(): 17 Metaprogramming, When You Still Need a Metaclass
__setstate__(): 25 Surrogate, The Recursion Trap; 29 Changing the Interface, Adapter in Python
- setter: 07 Classes, Adding a Setter; 09 Class Attributes, Two Dictionaries, One Lookup; 12 Data Classes as Types, A Class Is Not a Type; 26 Factory, Builder; 30 Observer, The Classic Observer; 30 Observer, Re-entrant Notification; 30 Observer, Observer and I/O
- shadows: 09 Class Attributes, Class Attributes Are Not Default Values
- a built-in name: 13 Pattern Matching; 31 State Machines, Each State Decides; B An Effect Checker, Facts About a Function
- a class attribute: 09 Class Attributes, Two Dictionaries, One Lookup; 09 Class Attributes, A Shared Mutable Value; 09 Class Attributes, Declaring Shared State with ClassVar; 09 Class Attributes, ClassVar and Inheritance; 09 Class Attributes, Real Per-Object Defaults; 17 Metaprogramming, A Descriptor That Learns Its Name
- shallow: 02 Tour, Variables and References; 03 Containers, Shallow Immutability; 16 Comprehensions, Unpacking in Comprehensions; 20 Rethinking Objects, Plugging Leaks Is Tedious; 20 Rethinking Objects, The Immutability Solution; 35 Flyweight, Freezing the Shared Tile; 40 Foundations, Immutability in Annotations
shout(): 02 Tour, t-Strings; 08 Static Types, Narrowing; 40 Foundations, Functions as First-Class Objects; 41 Toolkits, partial; A Effect Tracking, A Row Inside Annotated; A Effect Tracking, Resolve Every Call; B An Effect Checker, The Check
ShutDown: 19 Concurrency, Coordinating Threads with Queues
- side cause: 44 Effect Management, What Is an Effect?; 05 Functions, Names Inside a Function; 44 Effect Management, Are Exceptions Impure?; 44 Effect Management, Two Phases of Effect Analysis
- examples of: 44 Effect Management, What Is an Effect?; 46 Stateless, A Clock That Never Waits; 47 Stateless in Practice, A Coin Toss; 47 Stateless in Practice, A Clock; 47 Stateless in Practice, A Source Named in the Type; 47 Stateless in Practice, State as an Ability
- made replaceable: 44 Effect Management, Two Phases of Effect Analysis; 44 Effect Management, Effects by Hand; 46 Stateless, Dependency Injection; 46 Stateless, A Clock That Never Waits
- side effect: 40 Foundations, Pure Functions; 44 Effect Management, What Is an Effect?; 44 Effect Management, Are Exceptions Impure?; 44 Effect Management, Two Phases of Effect Analysis
- declared to Stateless: 46 Stateless, Declaring a Dependency; 47 Stateless in Practice, A Source Named in the Type; 47 Stateless in Practice, State as an Ability
- in a comprehension: 16 Comprehensions, Comprehensions Build, Loops Execute; 16 Comprehensions, Choosing a Form
- in tests: 11 Testing, Fixtures Replace Setup and Teardown; 11 Testing, Filesystem and Environment; 44 Effect Management, Two Phases of Effect Analysis; 44 Effect Management, Effects by Hand
- of registration: 14 Decorators, Decorating Classes; 26 Factory, Hazards of Self Registration
- skipped by a cache: 18 Performance, Caching; 41 Toolkits,
cache; 41 Toolkits, lru_cache
- Sidecar: 39 Pattern Catalog, Finding a Pattern by Problem; 39 Pattern Catalog, Distributed and Cloud
SimpleNamespace: 28 Data Transfer Objects, SimpleNamespace; 12 Data Classes as Types, The General Form of replace(); 28 Data Transfer Objects, A Hand-Rolled Messenger; 28 Data Transfer Objects, Which Should You Use?
singledispatch: 37 Pattern Refactoring, One singledispatch Function per Operation; 41 Toolkits, singledispatch; 20 Rethinking Objects, What Is Polymorphism?; 32 Multiple Dispatching, One Type or Many; 37 Pattern Refactoring, Choosing the Lightest Construct
- for Visitor: 33 Visitor, The Pythonic Visitor: singledispatch; 33 Visitor, One Dispatch Is Enough
singledispatchmethod: 32 Multiple Dispatching, The singledispatchmethod Trap; 41 Toolkits, singledispatchmethod; 33 Visitor, The Pythonic Visitor: singledispatch; 37 Pattern Refactoring, One singledispatch Function per Operation; 41 Toolkits, The functools Toolkit
- Singleton: 23 Singleton, A Module Is Already a Singleton; 23 Singleton, Borg: Singleton by Inheritance; 23 Singleton, Singleton by Class Decorator; 21 Design Patterns, When a Pattern Dissolves; 23 Singleton; 26 Factory; 29 Changing the Interface, Façade; 39 Pattern Catalog, Finding a Pattern by Problem
- slice: 03 Containers, Indexing and Slicing; 18 Performance, Memory View; 19 Concurrency; 19 Concurrency, Why Speedup Isn't Linear; 22 Iterators, Reusable Algorithms; 41 Toolkits,
islice; 41 Toolkits, Lazy Evaluation
__slots__: 09 Class Attributes, Class Attributes Are Not Default Values; 09 Class Attributes, Two Dictionaries, One Lookup; 17 Metaprogramming, __init__() versus __new__() in a Metaclass; 18 Performance, Reduce Memory Overhead; 18 Performance, Slots; 20 Rethinking Objects, Abstract Base Classes; 29 Changing the Interface, Adapter; 47 Stateless in Practice, Abilities Are Not Special
__slots__ = (): 18 Performance, A Decorator for the Default; 28 Data Transfer Objects, Subclassing tuple Directly
- where slots do not fit: 10 Cleanup, A Slotted Class Needs
__weakref__; 18 Performance, When Slots Does Not Fit
slow: 18 Performance, Reading a cProfile Report; 18 Performance, Converting a Slow Function to Rust; 19 Concurrency, Bounding a Wait with asyncio.timeout(); 19 Concurrency, Coordinating Threads with Queues; 30 Observer, A Failing Responder Orphans the Rest
- smart reference: 25 Surrogate, What Proxy Solves; 25 Surrogate, Smart Reference
socket.socket: 10 Cleanup, The Rule
- soft keywords: 04 Control Flow, Pattern Matching; 13 Pattern Matching
spawn(): 19 Concurrency, What a Process Pool Requires; 19 Concurrency, Measuring the Time; 26 Factory, Prototype; 38 Simulation, The Rat and the Blackboard
- Splitter: 39 Pattern Catalog, Finding a Pattern by Problem; 39 Pattern Catalog, Integration and Messaging (Hohpe and Woolf)
- stable hash: 40 Foundations, A Stable Hash and Safe Sharing
starmap: 41 Toolkits, starmap
stat(): 19 Concurrency, Measuring the Memory; 34 Composite and Interpreter, A Composite of Data Classes
- State: 25 Surrogate, State; 21 Design Patterns, Pattern Taxonomy; 25 Surrogate; 25 Surrogate, One Surrogate, Two Intents; 31 State Machines, Mousetrap States; 39 Pattern Catalog; 39 Pattern Catalog, Finding a Pattern by Problem; 39 Pattern Catalog, Other Patterns and Idioms
- State effect: 47 Stateless in Practice, State as an Ability
- State Machine: 31 State Machines, Table-Driven State Machine; 25 Surrogate, State; 31 State Machines; 31 State Machines, Mousetrap States; 31 State Machines, Which Design Should You Use?; 39 Pattern Catalog; 39 Pattern Catalog, Finding a Pattern by Problem; 39 Pattern Catalog, Other Patterns and Idioms
@staticmethod: 07 Classes, Static and Class Methods; 14 Decorators, Decorators as Classes; 14 Decorators, Decorators You Already Know; 17 Metaprogramming, Writing a Metaclass; 24 Template Method, Hooks and the Misspelled Override; 26 Factory, Simple Factory Method; 29 Changing the Interface, Façade; B An Effect Checker, What the Checker Resolves, and What It Cannot See
StopIteration: 16 Comprehensions, A Generator Expression Runs Once; 22 Iterators, Iteration Comes Built In; 22 Iterators, An Exhausted Generator Is Silently Empty; 22 Iterators, first() and current_item() Rebuild the List; 22 Iterators, Asking Consumes an Item; 22 Iterators, The Protocol Answers Nothing; 45 Generators, The Driver You Already Use; 46 Stateless, An Effect Runs Once; 47 Stateless in Practice, A Coin Toss
StopIteration.value: 45 Generators, Annotating a Generator; 45 Generators, A Generator Is a Description; 45 Generators, The Return Channel; 45 Generators, The Send Channel; 45 Generators, Composing Is Not Interpreting; 46 Stateless, The Simplest Effect; 46 Stateless, Nothing Runs Yet
__str__(): 06 Modules and Packages; 07 Classes, Marking Overrides with @override; 07 Classes, String Representation; 12 Data Classes as Types, Mixing a Type into an Enum; 25 Surrogate, Special Methods Bypass __getattr__(); 32 Multiple Dispatching, Two Dispatches Through Methods
- strategy: 21 Design Patterns, When a Pattern Dissolves; 21 Design Patterns, A Pattern Moves an Edge; 24 Template Method, Passing the Steps as Functions; 27 Function Objects; 27 Function Objects, Strategy: Choosing the Algorithm at Runtime; 27 Function Objects, Chain of Responsibility: Choosing the Handler at Runtime; 27 Function Objects, Choosing the Lightest Callable; 39 Pattern Catalog, Finding a Pattern by Problem; 43 Confidence, The Same Law in Hypothesis; 18 Performance, Choosing a Strategy; 19 Concurrency, Why Speedup Isn't Linear; 47 Stateless in Practice, 5. Much of a mature Effect system is missing
StrEnum: 12 Data Classes as Types, Mixing a Type into an Enum; 30 Observer, The Model; 31 State Machines, Each State Decides; 32 Multiple Dispatching; 32 Multiple Dispatching, Testing Both Versions; 38 Simulation, The Rat and the Blackboard
- strong reference: 10 Cleanup,
weakref.finalize() as a Backstop; 19 Concurrency, Structured Concurrency with TaskGroup; 26 Factory, Hazards of Self Registration; 30 Observer, Lapsed Listeners; 30 Observer, Setting the Responders at Construction; 35 Flyweight, A Pool That Does Not Leak; 41 Toolkits, cache
- structural typing: 08 Static Types, Structural Typing with Protocols; 08 Static Types, Structural Typing; 14 Decorators, The Decorator Pattern; 20 Rethinking Objects, Protocols Generalize, Composition Adapts; 26 Factory, Abstract Factories; 38 Simulation; 38 Simulation, The Rat and the Blackboard
- Structured Concurrency: 19 Concurrency, Structured Concurrency with
TaskGroup; 39 Pattern Catalog, Finding a Pattern by Problem; 39 Pattern Catalog, Concurrency (POSA and others); 19 Concurrency, Concurrency Is Not Easy
Sub: 09 Class Attributes, type(self) Forks the Counter; 17 Metaprogramming, Making a Class Final; 17 Metaprogramming, Multiple Inheritance and Metaclasses; 23 Singleton, Singleton by Class Decorator
__subclasses__(): 26 Factory, Simple Factory Method; 26 Factory, Hiding the Concrete Classes; 26 Factory, Self Registration; 32 Multiple Dispatching; 38 Simulation, Rooms, Robots, and the Item Factory
- submodule: 06 Modules and Packages, Packages; 06 Modules and Packages, Imports Within a Package; 06 Modules and Packages, Deferring an Import Before 3.15; 29 Changing the Interface, Façade
- subtype polymorphism: 20 Rethinking Objects, What Is Polymorphism?
- sum type: 42 Error Handling, Return the Error as a Value
super(): 07 Classes, Inheritance; 07 Classes, Method Resolution Order; 17 Metaprogramming, A Family of Generated Classes; 17 Metaprogramming, Generating Classes with exec(); 17 Metaprogramming, Writing a Metaclass; 17 Metaprogramming, Intercepting Instance Creation; 21 Design Patterns, What One Part Knows About Another; see also method resolution order
- in __new__() or a metaclass: 17 Metaprogramming, Intercepting Instance Creation; 35 Flyweight, Interning in the Constructor
super().__init__(): 07 Classes, Inheritance; 07 Classes, Calling the Base Constructor; 17 Metaprogramming, A Family of Generated Classes; 23 Singleton, Borg: Singleton by Inheritance; 24 Template Method, Don't Start the Engine in the Constructor; 30 Observer, The Classic Observer; 30 Observer, The Pythonic Observer
super().__init_subclass__(): 17 Metaprogramming, Self-Registration of Subclasses; 30 Observer, Decorated Responders
suppress: 02 Tour, Naming Conventions; 15 Context Managers, The __exit__() Arguments; 15 Context Managers, The expected Manager; 15 Context Managers, Context Manager as Decorator; 15 Context Managers, The contextlib Toolkit; 15 Context Managers, An Object Pool; 15 Context Managers, Choosing a Form
__suppress_context__: 04 Control Flow, Exception Chaining
- Surrogate: 25 Surrogate, A Surrogate Is Not Its Implementation; 25 Surrogate, One Surrogate, Two Intents; 25 Surrogate; 29 Changing the Interface, Adapter in Python; 39 Pattern Catalog, Other Patterns and Idioms
- suspends: 19 Concurrency,
async def, await, and the Event Loop; 19 Concurrency, time.sleep() Stops the Loop; 19 Concurrency, Coordinating Threads with Queues; 44 Effect Management, Native Effect Management; 45 Generators; 45 Generators, The Driver You Already Use
switch: 04 Control Flow, Pattern Matching; 13 Pattern Matching; 13 Pattern Matching, Matching Values; 13 Pattern Matching, Exhaustive Matching; 18 Performance, The Tail-Calling Interpreter; 31 State Machines, A Vending Machine
SyntaxError: 05 Functions, Default Parameter Values; 06 Modules and Packages, Limits of lazy; 16 Comprehensions, Scope and the Walrus Operator; 16 Comprehensions, Nested Comprehensions; 16 Comprehensions, Generator Expressions; 30 Observer, Observer and I/O; 34 Composite and Interpreter, Simplification Rewrites the Tree; 45 Generators, The Driver You Already Use
- in match patterns: 13 Pattern Matching, Alternatives and Capture; 13 Pattern Matching, A Bare Name Captures, a Dotted Name Compares; 13 Pattern Matching, Built-in Types and Subclasses; 13 Pattern Matching, Guards; 13 Pattern Matching, Patterns Nest
SyntaxWarning: 04 Control Flow, Errors and Exceptions; 35 Flyweight, Python Uses Flyweights
sys: 18 Performance, The Tail-Calling Interpreter
sys._jit: 18 Performance, The CPython JIT
sys._jit.is_active(): 18 Performance, The CPython JIT
sys.getsizeof(): 18 Performance, Slots; 18 Performance, Array Instead of List; 18 Performance, Memory View
sys.lazy_modules: 06 Modules and Packages, Watching the Deferral
sys.modules: 06 Modules and Packages; 06 Modules and Packages, Circular Imports; 06 Modules and Packages, File Names; 06 Modules and Packages, Deferring an Import Before 3.15; 23 Singleton, A Module Is Already a Singleton
sys.monitoring: 18 Performance, Measuring One Function with sys.monitoring
sys.path: 06 Modules and Packages, Circular Imports; 06 Modules and Packages, PYTHONPATH; 11 Testing, pytest
sys.setrecursionlimit(): 41 Toolkits, Recursion
sys.settrace(): 18 Performance, Measuring One Function with sys.monitoring
sys.stderr: 10 Cleanup, Why __del__() Is Not Cleanup
sys.stdout: 11 Testing, Isolating Tests from the World; 15 Context Managers, The contextlib Toolkit
SystemExit: 04 Control Flow, Errors and Exceptions; 15 Context Managers, The expected Manager
T
- t-string: 02 Tour, t-Strings
TabError: 02 Tour, Indentation and Blocks
- tail-call optimization: 41 Toolkits, Recursion; 18 Performance, The Tail-Calling Interpreter
- tail-resumptive: 47 Stateless in Practice, 3. Handlers cannot capture the continuation
takewhile(): 41 Toolkits, takewhile; 22 Iterators, Reusable Algorithms; 41 Toolkits, Composing the Pieces
tally(): 05 Functions, Positional-Only and Keyword-Only Parameters; 40 Foundations, Closures
- task: 19 Concurrency,
async def, await, and the Event Loop
TaskGroup: 19 Concurrency, Structured Concurrency with TaskGroup; 15 Context Managers, The Async Protocol; 19 Concurrency, Bounding a Wait with asyncio.timeout(); 19 Concurrency, One await, Any Backend; 19 Concurrency, Are Threads Still Necessary?; 19 Concurrency, Guidelines; 38 Simulation, The Rat and the Blackboard
tee(): 22 Iterators, What tee() Buffers; 41 Toolkits, tee; 18 Performance, Numbers on Your Machine; 19 Concurrency, Sharing an Iterator Between Threads; 22 Iterators, first() and current_item() Rebuild the List; 22 Iterators, Asking Consumes an Item; 22 Iterators, The Protocol Answers Nothing; 25 Surrogate, State
- telescoping constructor: 26 Factory, Builder
tempfile.TemporaryDirectory(): 16 Comprehensions, Supplying the Input Iterable
Template: 02 Tour, t-Strings; 34 Composite and Interpreter, A Template Is a Tree
- Template Method: 24 Template Method; 24 Template Method, The Anchored Algorithm; 24 Template Method, Substitutability; 24 Template Method, Passing the Steps as Functions; 39 Pattern Catalog, Finding a Pattern by Problem
textwrap.fill(): 15 Context Managers, The expected Manager; 15 Context Managers, The expect() Function
- thread: 19 Concurrency, Context That Follows the Call Chain
- thread of execution: 19 Concurrency
- Thread Pool: 39 Pattern Catalog, Finding a Pattern by Problem; 39 Pattern Catalog, Concurrency (POSA and others); 19 Concurrency; 19 Concurrency, I/O-Bound vs CPU-Bound; 19 Concurrency, Threads Overlap Waits, Not Computing; 19 Concurrency, Subinterpreters; 19 Concurrency, One
await, Any Backend; 19 Concurrency, Are Threads Still Necessary?
- Thread-Specific Storage: 39 Pattern Catalog, Concurrency (POSA and others)
threading: 19 Concurrency, The GIL Does Not Prevent Races
threading.Barrier: 19 Concurrency, Concurrency Is Not Easy
threading.concurrent_tee(): 19 Concurrency, Sharing an Iterator Between Threads; 19 Concurrency, Guidelines; 22 Iterators, What tee() Buffers
threading.Event: 19 Concurrency, Measuring the Time
threading.local: 19 Concurrency, Context That Follows the Call Chain
threading.Lock: 15 Context Managers, An Empty Pool Blocks the Borrower; 19 Concurrency, A Single Thread Still Races; 19 Concurrency, Locks; 19 Concurrency, The GIL Does Not Prevent Races; 19 Concurrency, Guidelines; 23 Singleton, Tests, Threads, and Locks; 23 Singleton, The First-Call Race; 23 Singleton, Double-Checked Locking and Eager Creation
threading.serialize_iterator(): 19 Concurrency, Sharing an Iterator Between Threads; 19 Concurrency, Guidelines
threading.stack_size(): 19 Concurrency, Measuring the Memory
threading.synchronized_iterator(): 19 Concurrency, Sharing an Iterator Between Threads; 19 Concurrency, Guidelines; 45 Generators, A Generator Is a Description
ThreadPoolExecutor: 19 Concurrency, Raw multiprocessing; 19 Concurrency, One Executor Interface, Three Pools; 47 Stateless in Practice, Running Effects in Parallel
throw(): 45 Generators, throw() and close() Reach the Innermost Generator; 15 Context Managers, A Basic Context Manager; 19 Concurrency, Sharing an Iterator Between Threads; 22 Iterators, Delegating with yield from; 45 Generators, The Driver You Already Use; 46 Stateless, Catching Is Not Handling; 47 Stateless in Practice, Failing from Inside an Effect
stateless.throw(): 46 Stateless, The Simplest Effect; 47 Stateless in Practice, Failing from Inside an Effect; 47 Stateless in Practice, The Toolkit
@throws: 46 Stateless, Declaring a Failure with @throws; 46 Stateless, Declaring Is Not Handling; 46 Stateless, Multiple Errors
- tight coupling: 21 Design Patterns, Coupling
- time-sharing: 19 Concurrency
time.monotonic(): 11 Testing, The Clock
time.perf_counter(): 11 Testing, The Clock; 18 Performance, Trusting a Measurement
timedelta: 32 Multiple Dispatching, Operators Dispatch Twice; 47 Stateless in Practice, A Clock; 47 Stateless in Practice, A Clock That Crosses Midnight; 47 Stateless in Practice, retry() and a Flaky Database; 47 Stateless in Practice, repeat() and memoize()
timeit: 18 Performance, Benchmark Alternatives with timeit; 03 Containers, Sets; 18 Performance, Trusting a Measurement
- Timeout: 39 Pattern Catalog, Finding a Pattern by Problem; 39 Pattern Catalog, Distributed and Cloud; 15 Context Managers, What the Skeleton Leaves Out; 19 Concurrency, Bounding a Wait with
asyncio.timeout(); 19 Concurrency, Livelock; 47 Stateless in Practice, 5. Much of a mature Effect system is missing
TimeoutError: 19 Concurrency, Bounding a Wait with asyncio.timeout(); 19 Concurrency, Deadlock
tkinter: 30 Observer, A Visual Example; 30 Observer, The Model; 30 Observer, The View; 38 Simulation, Watching the Pack; 38 Simulation, Watching the Robot; 38 Simulation, Watching It Happen
- Total Function: 42 Error Handling, Total Functions; 44 Effect Management, Are Exceptions Impure?
total_ordering: 41 Toolkits, total_ordering
traceback.format_exception_only(): 42 Error Handling, Attaching Context to an Exception
__traceback__: 42 Error Handling, Attaching Context to an Exception
tracemalloc: 18 Performance, Numbers on Your Machine; 18 Performance, Lazy Evaluation with Generators; 19 Concurrency, Measuring the Memory; 22 Iterators, Generators
- Transaction Script: 39 Pattern Catalog, Finding a Pattern by Problem; 39 Pattern Catalog, Enterprise Application (Fowler)
Trash: 37 Pattern Refactoring, The Trash Hierarchy; 09 Class Attributes, type(self) Forks the Counter; 37 Pattern Refactoring, The Data File and Its Parser; 37 Pattern Refactoring, The First Cut: Checking Every Type; 37 Pattern Refactoring, Let a Dictionary Do the Sorting; 37 Pattern Refactoring, A Method on Every Material; 37 Pattern Refactoring, One singledispatch Function per Operation
- truthiness: 02 Tour, Booleans, None, and Truthiness; 05 Functions, Sentinel Values; 08 Static Types, Narrowing; 27 Function Objects, Chain of Responsibility: Choosing the Handler at Runtime
- tuple: 03 Containers, Tuples and Unpacking
- type: 12 Data Classes as Types; 21 Design Patterns, Coupling; 23 Singleton, Singleton by Class Decorator; 37 Pattern Refactoring, Adding Operations: Visitor, and Why Python Skips It
- type hints: 08 Static Types; 08 Static Types, Type Hints; 08 Static Types, Gradual Typing; 08 Static Types, Hints Are Not Enforced at Run Time; 08 Static Types, Type Hint Summary; 17 Metaprogramming, The Core Functions
- Type Object: 39 Pattern Catalog, Other Patterns and Idioms
- type parameter: 08 Static Types, Type Parameters
- type statement: 08 Static Types, Naming Types: The
type Statement
TYPE_CHECKING: 06 Modules and Packages, Circular Imports; 08 Static Types, Typing Decorators and Directives; 38 Simulation, Rooms, Robots, and the Item Factory
__type_params__: 14 Decorators, wraps Keeps the Runtime Interface
TypedDict: 08 Static Types, Typing **kwargs with a TypedDict; 08 Static Types, Dictionary and Record Shapes; 28 Data Transfer Objects, Which Should You Use?
TypeFailure: 12 Data Classes as Types, check() and TypeFailure; 12 Data Classes as Types, A Class Is Not a Type; 12 Data Classes as Types, Parse, Don't Validate; 12 Data Classes as Types, Composing Types from Types; 12 Data Classes as Types, Enums Are Types Too; 12 Data Classes as Types, A NamedTuple Cannot Validate Itself; 12 Data Classes as Types, The General Form of replace()
TypeIs: 08 Static Types, Type Narrowing; 16 Comprehensions, The map() and filter() Equivalent; B An Effect Checker, Facts About a Function
TypeVar: 08 Static Types, **P and the Older TypeVar Syntax; 08 Static Types, Generics
U
UnboundLocalError: 05 Functions, Names Inside a Function; 23 Singleton, The First-Call Race; 40 Foundations, Closures
- uncollectable: 10 Cleanup, Reference Cycles Delay Destruction
- Unit of Work: 39 Pattern Catalog, Finding a Pattern by Problem; 39 Pattern Catalog, Enterprise Application (Fowler); 19 Concurrency
unittest: 11 Testing, pytest; 11 Testing, Stubs and Mocks; 24 Template Method
unittest.mock: 11 Testing, Stubs and Mocks
Unknown: 08 Static Types, Gradual Typing; 12 Data Classes as Types, Defaults Built Fresh, Not Shared; 14 Decorators, What @ Does Not Require; 47 Stateless in Practice, Catching the Whole Channel; 47 Stateless in Practice, 2. The type checker decides what survives handling; A Effect Tracking, Find a Place to Run
- in the effect checker: A Effect Tracking, Decide What Untracked Code Performs; A Effect Tracking, Find a Place to Run; B An Effect Checker, The Restriction; B An Effect Checker, Effect Names and the Table; B An Effect Checker, The Check; B An Effect Checker, Effects for Code You Don't Own; B An Effect Checker, The Checker Checks Itself; B An Effect Checker, What the Checker Resolves, and What It Cannot See
Unpack: 08 Static Types, Typing **kwargs with a TypedDict; 08 Static Types, Generics; 08 Static Types, Dictionary and Record Shapes
update_wrapper(): 14 Decorators, A Stateless Class-Form Decorator; 14 Decorators, A Class-Form Decorator with State; 41 Toolkits, wraps
urlopen(): 11 Testing, Network Calls
uv: 01 Introduction, The Examples; 06 Modules and Packages, PYTHONPATH; 08 Static Types; 08 Static Types, The Type Checker: ty; 18 Performance, The Tail-Calling Interpreter; 18 Performance, Converting a Slow Function to Rust
V
- Value Object: 39 Pattern Catalog, Finding a Pattern by Problem; 39 Pattern Catalog, Enterprise Application (Fowler)
- value pattern: 13 Pattern Matching, A Bare Name Captures, a Dotted Name Compares; 30 Observer, Document-View and MVC
vars(): 09 Class Attributes, Two Dictionaries, One Lookup; 09 Class Attributes, Real Per-Object Defaults; 11 Testing, White-Box and Black-Box Tests; 12 Data Classes as Types, D: A Real ClassVar; 28 Data Transfer Objects, A Hand-Rolled Messenger
- vector of change: 21 Design Patterns, The Vector of Change; 37 Pattern Refactoring, Choosing the Lightest Construct; 37 Pattern Refactoring; 37 Pattern Refactoring, Adding Operations: Visitor, and Why Python Skips It
- view: 03 Containers, Dictionaries
- in a model-view design: 30 Observer, The View; 27 Function Objects, Strategy: Choosing the Algorithm at Runtime; 30 Observer, Re-entrant Notification; 30 Observer, The Model; 38 Simulation, Watching the Pack; 38 Simulation, Watching the Robot
- of memory: 18 Performance, Memory View; 03 Containers,
namedtuple
- onto live contents: 03 Containers, Immutability; 41 Toolkits,
groupby
- virtual proxy: 25 Surrogate, What Proxy Solves; 25 Surrogate, Virtual Proxy; 25 Surrogate, Smart Reference
- Visitor: 33 Visitor, The Classic Visitor; 33 Visitor, Where Visitor Still Fits; 37 Pattern Refactoring, Adding Operations: Visitor, and Why Python Skips It; 21 Design Patterns, A Pattern Moves an Edge; 33 Visitor; 33 Visitor, One Dispatch Is Enough; 39 Pattern Catalog, Finding a Pattern by Problem
- with singledispatch: 33 Visitor, The Pythonic Visitor: singledispatch; 37 Pattern Refactoring, One
singledispatch Function per Operation; 41 Toolkits, singledispatch
W
- walrus operator: 04 Control Flow, The Walrus Operator; 16 Comprehensions, Scope and the Walrus Operator; B An Effect Checker, Rows to a Fixed Point
warnings.deprecated(): 29 Changing the Interface, Deprecating the Old Interface
warnings.warn(): 29 Changing the Interface, Deprecating the Old Interface
- weak reference: 10 Cleanup,
weakref.finalize() as a Backstop; 10 Cleanup, The self.close Trap
- and slots: 10 Cleanup, A Slotted Class Needs
__weakref__; 18 Performance, When Slots Does Not Fit; 35 Flyweight, A Pool That Does Not Leak
- removing registry entries: 10 Cleanup, Watching Objects Without Holding Them; 30 Observer, Lapsed Listeners; 35 Flyweight, A Pool That Does Not Leak
WeakMethod: 30 Observer, Lapsed Listeners
weakref.proxy(): 10 Cleanup, A Slotted Class Needs __weakref__; 25 Surrogate, What Proxy Solves
__weakref__: 10 Cleanup, A Slotted Class Needs __weakref__; 17 Metaprogramming, The Tool in Use; 18 Performance, When Slots Does Not Fit; 35 Flyweight, A Pool That Does Not Leak
WeakValueDictionary: 10 Cleanup, A Slotted Class Needs __weakref__; 10 Cleanup, Watching Objects Without Holding Them; 35 Flyweight, A Pool That Does Not Leak; 35 Flyweight, Choosing a Flyweight and Its Pool
Weapon: 26 Factory, Abstract Factories; 47 Stateless in Practice, Supplying a Whole Cast; 47 Stateless in Practice, The Unmatched Cast
while: 04 Control Flow, Loops; 04 Control Flow, The Loop else Clause; 04 Control Flow, The Walrus Operator; 22 Iterators, Generators; 22 Iterators, Reusable Algorithms; 38 Simulation, Watching the Pack; 41 Toolkits, Groups of Any Size; B An Effect Checker, Rows to a Fixed Point
- white-box: 11 Testing, White-Box and Black-Box Tests
__wrapped__: 14 Decorators, wraps Keeps the Runtime Interface; 41 Toolkits, wraps
wrapper(): 14 Decorators, What @ Does; 14 Decorators, wraps Keeps the Runtime Interface; 14 Decorators, **P and R Keep the Static Interface; 14 Decorators, Decorators That Take Arguments; 14 Decorators, A Class-Form Decorator with State; 14 Decorators, A Class-Form Decorator with Arguments; 14 Decorators, A Limitation: Methods Need a Descriptor
wraps: 14 Decorators, wraps Keeps the Runtime Interface; 41 Toolkits, wraps; 15 Context Managers, Context Manager as Decorator; 17 Metaprogramming, Attributes on a Function; 42 Error Handling, Turning Exceptions into Results
Y
yield: 15 Context Managers, Context Manager as Decorator; 22 Iterators, The Body Waits for the First next(); 45 Generators, Annotating a Generator; 45 Generators, A Generator Is a Description; 45 Generators, The Send Channel; 45 Generators, The Driver You Already Use; see also generator
- as an expression (send): 45 Generators, The Return Channel; 45 Generators, The Send Channel; 45 Generators, All Three Channels
- in a context manager: 15 Context Managers, A Basic Context Manager; 15 Context Managers, The
__exit__() Arguments; 45 Generators, throw() and close() Reach the Innermost Generator
- in an Effect signature: 46 Stateless, Why
yield from; 46 Stateless, Retrofitting an Effect; 47 Stateless in Practice, Abilities Are Not Special; 47 Stateless in Practice, Failing from Inside an Effect; A Effect Tracking, A Row Inside Annotated
yield from: 22 Iterators, Delegating with yield from; 45 Generators, yield from Composes Descriptions; 46 Stateless, Why yield from; 45 Generators, Running to Exhaustion; 45 Generators, The Send Channel; 45 Generators, throw() and close() Reach the Innermost Generator; 46 Stateless, Effects Propagate, and the Type Checker Verifies It
Z
ZeroDivisionError: 04 Control Flow, Errors and Exceptions; 15 Context Managers, The __exit__() Arguments; 44 Effect Management, Are Exceptions Impure?; 47 Stateless in Practice, 1. Nothing stops an undeclared Effect
- as a Result: 42 Error Handling, Composing by Hand; 42 Error Handling, Turning Exceptions into Results; 42 Error Handling, Matching on the Error; 44 Effect Management, Return a Result Type; 44 Effect Management, Catch the Exception You Expect; 44 Effect Management, Combine the First and Third
zip(): 04 Control Flow, range(), enumerate(), and zip(); 03 Containers, Dictionaries; 16 Comprehensions, Supplying the Input Iterable; 22 Iterators, What tee() Buffers; 41 Toolkits, batched; 41 Toolkits, starmap; 41 Toolkits, zip_longest
zip_longest: 41 Toolkits, zip_longest; 41 Toolkits, batched