An iterable object is an object capable of returning its members one at a time.
To do so, it must define an __iter__
method that returns an iterator.
The iterator protocol specifies that, in order to be a valid iterator,
an object must define a __next__
and an __iter__
method (because iterators are also iterable).
Defining an __iter__
method that returns anything else than an iterator will raise a TypeError
as soon as the iteration
begins.
Note that generators and generator expressions have both __next__
and
__iter__
methods generated automatically.