[Python-Dev] Single- vs. Multi-pass iterability

Barry A. Warsaw barry@zope.com
Fri, 19 Jul 2002 13:07:29 -0400


>>>>> "A" == Aahz  <aahz@pythoncraft.com> writes:

    A> The for loop in Python <2.2 has an internal state object.
    A> Iterators are the external manifestation of that state object,
    A> generalized to objects other than sequences.  I'm surprised
    A> that anyone is surprised that the state object gets
    A> mutated/destroyed.  I'm also surprised that people are
    A> surprised about what happens when that state object is coupled
    A> to an inherently mutating object such as file objects.

Well said.
-Barry