[Tutor] iterators

Keith Winston keithwins at gmail.com
Sun Jan 19 19:47:55 CET 2014


Well, as usual thanks for all this, it's really great. I'd worked out
that it was a distinction between iterators and iterables, though I'm
going to Oscar's description a few more times: most of it made sense,
but there are subtleties.

For example, this from the Python 3.3 tutorial:

We say such an object is iterable [referring to "range"], that is,
suitable as a target for functions and constructs that expect
something from which they can obtain successive items until the supply
is exhausted. We have seen that the for statement is such an iterator.
The function list() is another; it creates lists from iterables:

Now, everything we've said thus far would not have led me to believe
that one would call the for statement an iterator... is this just
very, very loose use of the term (in the Python documentation!), or am
I still missing something biggish?

K


More information about the Tutor mailing list