Often you’ll need to process some sequence of data from one source or another. The way to do this in Python is to use iterators. Many of the data types available in standard Python include an iterable interface that you can use. For those that don't, you can create a generator that then provides an iterable interface.
3-1. Iterating Over the Contents of a List
You want to iterate over the contents of a list.
While a list is iterable, you need to use the iter function to get access to the associated iterator.
How It Works
Listing 3-1 shows how to get access to the associated ...