PYTHON
Python Generators
Article by:Geoffrey Hunter
Date Published: | |
Last Modified: |
Contents
Overview
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 return
.
Type Annotations
Generators can be annotated with the Generator
type that is defined in the typing
module:
|
|
Code Examples
The following code example chunks up a list:
|
|
Authors

This work is licensed under a Creative Commons Attribution 4.0 International License .