[Python-ideas] PEP 479: Change StopIteration handling inside generators
Ethan Furman
ethan at stoneleaf.us
Thu Nov 20 05:19:41 CET 2014
On 11/19/2014 04:25 PM, Steven D'Aprano wrote:
>
> Here is a description of the generator protocol which could easily lead
> the reader to conclude that raising StopIteration is the correct way to
> exit a generator:
>
> To support this protocol, functions with yield statement
> are compiled specially as generators. They return a generator
> object when they are called. The returned object supports the
> iteration interface with an automatically created __next__()
> method to resume execution. Generator functions may have a
> return simply terminates the generation of values by raising
> a StopIteration exceptions after any normal function exit.
>
> http://www.bogotobogo.com/python/python_generators.php
We are not, however, responsible for third-party documentation.
> At this point, I'm convinced that there is a good argument for a
> __future__ import changing this behaviour. But I suspect that making
> this the default behaviour in the future will break a lot of code.
Isn't that the case with every __future__ directive that becomes the standard? Folks have an entire minor release to
make the adjustment.
--
~Ethan~
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: OpenPGP digital signature
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20141119/9e55654d/attachment.sig>
More information about the Python-ideas
mailing list