[Python-Dev] Re: Single- vs. Multi-pass iterability
Barry A. Warsaw
Thu, 18 Jul 2002 18:05:31 -0400
>>>>> "GvR" == Guido van Rossum <firstname.lastname@example.org> writes:
>> Container-like objects usually support protocol 1. Iterators are
>> currently required to support both protocols. The semantics of
>> iteration come only from protocol 2; protocol 1 is present to make
>> iterators behave like sequences. But the analogy is weak -- unlike
>> ordinary sequences, iterators are "sequences" that are destroyed by
>> the act of looking at their elements.
GvR> (I could do without the last sentence, since this expresses a
GvR> value judgement rather than fact -- not a good thing to have
GvR> in a PEP's "specification" section.)
"...sequences. Note that the act of looking at an iterator's
elements mutates the iterator."