Replace paragraph that confused people into thinking that generators are no longer iterators.

This commit is contained in:
Guido van Rossum 2014-12-10 12:44:54 -08:00
parent 7c1ca6bcc1
commit 64c45d5078
1 changed files with 6 additions and 5 deletions

View File

@ -347,11 +347,12 @@ may improve structural clarity.
Explanation of generators, iterators, and StopIteration
=======================================================
Under this proposal, generators and iterators would be distinct, but
related, concepts. Like the mixing of text and bytes in Python 2,
the mixing of generators and iterators has resulted in certain
perceived conveniences, but proper separation will make bugs more
visible.
The proposal does not change the relationship between generators and
iterators: a generator object is still an iterator, and not all
iterators are generators. Generators have additional methods that
iterators don't have, like ``send`` and ``throw``. All this is
unchanged. Nothing changes for generator users -- only authors of
generator functions may have to learn something new.
An iterator is an object with a ``__next__`` method. Like many other
special methods, it may either return a value, or raise a specific