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

Chris Barker chris.barker at noaa.gov
Tue Nov 25 18:47:52 CET 2014


On Tue, Nov 25, 2014 at 9:30 AM, Wolfgang Maier <
wolfgang.maier at biologie.uni-freiburg.de> wrote:

> allow StopIteration to be raised anywhere, but let it bubble up only *one*
> frame.
> So if the next outer frame does not deal with it, the exception would be
> converted to UnhandledStopIteration (or something else) when it's about to
> bubble out of that outer frame.
> The builtin next() would simply reset the frame count by catching and
> reraising StopIteration raised inside its argument (whether that's an
> iterator's __next__ or a generator; note that in this scenario using raise
> StopIteration instead of return inside a generator would remain possible).
>

I also have no idea if this is practical from an implementation
perspective, but I like how it support my goal of keeping the behavior of
iterator classes and generators consistent.

-Chris




-- 

Christopher Barker, Ph.D.
Oceanographer

Emergency Response Division
NOAA/NOS/OR&R            (206) 526-6959   voice
7600 Sand Point Way NE   (206) 526-6329   fax
Seattle, WA  98115       (206) 526-6317   main reception

Chris.Barker at noaa.gov
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20141125/a4260a7b/attachment.html>


More information about the Python-ideas mailing list