[Python-Dev] PEP 479: Change StopIteration handling inside generators (original) (raw)

Nick Coghlan ncoghlan at gmail.com
Thu Nov 20 11:05:27 CET 2014


On 20 November 2014 06:15, Benjamin Peterson <benjamin at python.org> wrote:

On Wed, Nov 19, 2014, at 15:10, Guido van Rossum wrote: > There's a new PEP proposing to change how to treat StopIteration bubbling > up out of a generator frame (not caused by a return from the frame). The > proposal is to replace such a StopIteration with a RuntimeError (chained > to > the original StopIteration), so that only returning from a generator > (or > falling off the end) causes the iteration to terminate. > > The proposal unifies the behavior of list comprehensions and generator > expressions along the lines I had originally in mind when they were > introduced. It renders useless/illegal certain hacks that have crept into > some folks' arsenal of obfuscated Python tools. > > In Python 3.5 the proposed change is conditional on: > > from future import replacestopiterationingenerators Drive-by comment: This seems like a terribly awkward name. Could a shorter and sweeter name not be found?

I think my suggestion was something like "from future import generator_return".

I saw that style as somewhat similar to "from future import division" - it just tells you what the change affects (in this case, returning from generators), while requiring folks to look up the documentation to find out the exact details of the old behaviour and the new behaviour.

Cheers, Nick.

-- Nick Coghlan | ncoghlan at gmail.com | Brisbane, Australia -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.python.org/pipermail/python-dev/attachments/20141120/371dbbe7/attachment.html>



More information about the Python-Dev mailing list