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
|
Explanation of generators, iterators, and StopIteration
|
||||||
=======================================================
|
=======================================================
|
||||||
|
|
||||||
Under this proposal, generators and iterators would be distinct, but
|
The proposal does not change the relationship between generators and
|
||||||
related, concepts. Like the mixing of text and bytes in Python 2,
|
iterators: a generator object is still an iterator, and not all
|
||||||
the mixing of generators and iterators has resulted in certain
|
iterators are generators. Generators have additional methods that
|
||||||
perceived conveniences, but proper separation will make bugs more
|
iterators don't have, like ``send`` and ``throw``. All this is
|
||||||
visible.
|
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
|
An iterator is an object with a ``__next__`` method. Like many other
|
||||||
special methods, it may either return a value, or raise a specific
|
special methods, it may either return a value, or raise a specific
|
||||||
|
|
Loading…
Reference in New Issue