Given a sequence , this function returns an iterator that generates the
elements of the sequence. For more information, see Section 24.2, “Iterators: Values that can produce a sequence of
values”.
S
>>> listWalker = iter ( [23, 47, 'hike'] ) >>> for x in listWalker: print x, ... 23 47 hike
In general, the calling sequence is:
iter(s[,sentinel])
If the argument is omitted, the first argument
must be either a sequence value that implements the
sentinel.__getitem__() method or an instance
of a class that has the .__iter__() method.
If you provide a argument, the sentinel argument must
be callable. The iterator returned will call s with no
arguments and generate the values it returns until
the return value equals s(), at which point it
will raise sentinelStopIteration.