Replace Ping's value judgement by a more neutral explanation of why

iterators need to support __iter__.
This commit is contained in:
Guido van Rossum 2002-07-19 04:25:06 +00:00
parent 9aee42f23e
commit a2d549a704
1 changed files with 2 additions and 6 deletions

View File

@ -163,12 +163,8 @@ Python API Specification
Container-like objects usually support protocol 1. Iterators are Container-like objects usually support protocol 1. Iterators are
currently required to support both protocols. The semantics of currently required to support both protocols. The semantics of
iteration come only from protocol 2; protocol 1 is present to make iteration come only from protocol 2; protocol 1 is present to make
iterators behave like sequences. But the analogy is weak -- unlike iterators behave like sequences; in particular so that code
ordinary sequences, iterators are "sequences" that are destroyed receiving an iterator can use a for-loop over the iterator.
by the act of looking at their elements.
Consequently, whenever any Python programmer says "for x in y",
he or she must be sure of whether this is going to destroy y.
Dictionary Iterators Dictionary Iterators