Search across all documentation pages
12 pages in this section.
Why Python's patterns look different from other languages' design patterns - the dynamic object model and dunder-method protocol underneath EAFP, context managers, strategy, and dependency injection - the mental model behind every other page in this section.
Learn 10 Pythonic Patterns, including EAFP key lookups, context managers for files, and strategy dictionaries to replace if/elif chains.
Understand EAFP and LBYL patterns in Python. Learn when to use "Easier to Ask Forgiveness" with exceptions versus "Look Before You Leap" with checks.
Learn how Python context managers guarantee resource setup and teardown, manage temporary state, and handle transactions reliably.
Replace if/elif chains with strategy registries or singledispatch for extensible dispatch patterns in Python. Learn when to apply each.
Learn to use Factory and Builder patterns in Python to construct complex objects, manage dependencies, and simplify object creation logic.
Learn how Observer and Pub/Sub patterns decouple components in Python. Implement event handling with callables, lists, or libraries like Blinker.
Avoid None ambiguity with sentinels and null objects. Learn to distinguish missing data, handle default mutable arguments, and implement no-op behaviors.
Learn Pythonic best practices for readable, maintainable code. Explore patterns from EAFP and with statements to dependency injection and domain events.
A single-page roundup of every highlight bullet from the 11 pages in the Pythonic Patterns section, grouped by source page so you can scan all 64 takeaways without opening each article individually.