Article by:Geoffrey Hunter
Python generators are a type of iterator in Python, with the important caviat that you can only iterate over them once.
They are created by writing a function what uses the keyword
yield rather than
Generators can be annotated with the
Generator type that is defined in the
The following code example chunks up a list:
This work is licensed under a Creative Commons Attribution 4.0 International License .