[Python-ideas] PEP 479: Change StopIteration handling inside generators

Steven D'Aprano steve at pearwood.info
Tue Nov 18 00:56:42 CET 2014


On Mon, Nov 17, 2014 at 11:38:27AM -0800, Guido van Rossum wrote:

> Hopefully the new version will soon be here:
> 
>   https://www.python.org/dev/peps/pep-0479
> 
> Note that I am definitely not yet deciding on this PEP. I would love it if
> people sent in examples of code using generator expressions that would be
> affected by this change (either by highlighting a bug in the code or by
> breaking what currently works).

Over a week ago I raised this issue on python-list mailing list. I 
expected a storm of bike-shedding, because that's the sort of place p-l 
is :-) but got just two people commenting.

The thread, for anyone interested:

https://mail.python.org/pipermail/python-list/2014-November/680757.html

One response suggested that it is not generators which do the wrong 
thing, but comprehensions, and that comprehensions should be changed to 
behave like generators:

https://mail.python.org/pipermail/python-list/2014-November/680758.html

That should probably be put in the PEP, even if it is not an option 
being considered, it at least evidence that "some people" find the 
behaviour of generators more natural than that of comprehensions.


-- 
Steve


More information about the Python-ideas mailing list