On Tue, Nov 25, 2014 at 9:30 AM, Wolfgang Maier <wolfgang.maier@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@noaa.gov