Browse by Topic

Popular

Latest

Latest Posts

Illustration of a Python generator delegating a stream of values to a subgenerator through a yield from connection.
Python

Python Generator Delegation with yield from

Python's yield from enables generator delegation by forwarding send, throw, and close to a subgenerator, with practical pipeline examples.

yield fromgeneratorsiteratorscoroutines
Illustration of a Python generator delegating iteration to a subgenerator through yield from.
Python

Python yield from: Delegating to Subgenerators

How python yield from delegates iteration to subgenerators, forwards send() and throw() calls, and enables coroutine composition in Python.

generatorscoroutinesiterationpython
Illustration of a Python generator being closed with a shield representing resource cleanup.
Python

Python Generator close: Deterministic Cleanup

A practical guide to Python generator close(): how close() triggers GeneratorExit, runs finally blocks, and releases resources deterministically.

PythonGeneratorsGeneratorExitResource Cleanup
An illustration of a Python generator receiving an injected exception at its yield point, showing the throw() method in action.
Python

How Python's generator.throw() Works

Learn how Python's generator.throw() injects exceptions at a suspension point, how to catch them inside the generator, and when to use throw() for cancellation and cleanup.

pythongeneratorsexceptionscoroutines
Illustration of a Python generator with send() passing a value into a paused generator, showing two-way communication.
Python

Python Generator send() Explained with Examples

Learn how the send() method on Python generators enables two-way communication, turning generators into simple coroutines for incremental data flow.

generatorssendcoroutinesyield
Illustration of a Python generator with a send arrow entering the yield expression, representing bidirectional data flow.
Python

Using send() with Python Generators

Learn how Python's generator `send()` method lets you pass values into a running generator, with examples covering priming, stateful consumers, error handling, and trade-offs.

generatorsyieldcoroutinespython-advanced
Illustration of a generator object being advanced by the next() function, showing paused and resumed execution states.
Python

Python next generator: How next() Drives Execution

python next generator: Learn how Python's next() drives generator execution, handles StopIteration, and works with yield, send, and yield from in practical code.

generatorsnext()yieldStopIteration
A visual comparison of Python's yield and return, showing a generator producing values lazily versus a function returning a single result.
Python

Python Yield vs Return: When to Use Each

python yield vs return: Understand the difference between yield and return in Python, how generators work, and when to choose each for memory-efficient code.

generatorsiteratorsfunction-returnpython-syntax
Illustration comparing Python generators and iterators, showing lazy evaluation and memory efficiency.
Python

Python Generator vs Iterator: Key Differences

Understand the difference between Python generators and iterators, how each works, and when to use each for memory-efficient code.

pythongeneratorsiteratorslazy evaluation
Illustration comparing a compact generator pipeline to a memory-heavy list, showing lazy vs eager evaluation.
Python

Python Generator vs List: Choosing the Right Iteration Tool

Understand the practical differences between Python lists and generators, including memory behavior, iteration semantics, and when to choose each.

generatorslistsiterationmemory usage