Python Iterators vs Generators
Compare Python iterators and generators side by side, understand when to use each, and learn the tradeoffs between custom iterator classes and generator functions.
Learn Python programming from scratch
Compare Python iterators and generators side by side, understand when to use each, and learn the tradeoffs between custom iterator classes and generator functions.
Explore Python's built-in functions for working with iterators, including map, filter, zip, enumerate, reversed, sorted, and the powerful itertools module.
Avoid the most common pitfalls with Python iterators and generators, including exhaustion, late binding, accidental materialization, and misuse of send().
Learn how to build a complete data processing pipeline in Python using generators, from reading input to writing output, with lazy evaluation at every stage.
Learn what Python decorators are, how the @ syntax works, and why decorators are a fundamental tool for writing reusable, composable behaviour in Python.
Learn to write your first Python decorator from scratch, understand the wrapper function pattern, and build a working timing decorator step by step.
Learn how to write Python decorators that work with functions accepting any number of positional and keyword arguments by forwarding them correctly.
Learn how to preserve, inspect, and transform return values in Python decorators, and why the wrapper must always return the result of calling the original function.
Learn how to build Python decorators that accept their own arguments by adding a factory function layer, enabling configurable behaviour like custom log levels and retry counts.
Learn why decorators erase function metadata and how functools.wraps preserves the original name, docstring, and attributes of wrapped functions.
Learn how to use Python classes as decorators, why the __call__ method makes it possible, and when class-based decorators are cleaner than nested functions.
Explore practical real-world applications of Python decorators including authentication, caching, rate limiting, input validation, and observability patterns.