What are generator send, throw, and close methods?
Generators and yield
Audio flashcard · 0:15Nortren·
What are generator send, throw, and close methods?
0:15
Send passes a value into a paused generator, which becomes the result of the corresponding yield expression. Throw raises an exception inside the generator at the point of yield. Close raises GeneratorExit, asking the generator to clean up and stop. These methods enable coroutine-like patterns.
docs.python.org