Last time I began exploring Python generator functions. I mostly covered their basic function as iterables, and why they’re good in for-loops. They’re also good for infinite lists. Much of their value lies in how they defer processing an item until it is actually asked for.
This time I’ll dig into the send
method, which allows sending messages to a running generator. I’ll also introduce the yield from
statement, which allows us to wrap a generator with another function that also acts like a generator.