Exploration of Python iterators and how they work.
Supporting content for this blog post.
Python provides for
loops for looping over a collection of items.
Iterators are the supporting concept that makes this work.
These example scripts illustrate Python-level details of how this works.
Requries python3. For convenience, you can create a virtual environment:
$ virtualenv venv -p python3
$ source venv/bin/activate
but stock Python3 is sufficient.
$ python3 <script_name>
# or
(venv) $ python <script_name>