Replace paragraph that confused people into thinking that generators are no longer iterators.
This commit is contained in:
parent
7c1ca6bcc1
commit
64c45d5078
11
pep-0479.txt
11
pep-0479.txt
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue