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

Chris Angelico rosuav at gmail.com
Mon Nov 24 18:07:57 CET 2014


On Tue, Nov 25, 2014 at 3:41 AM, Chris Barker <chris.barker at noaa.gov> wrote:
> On Sat, Nov 22, 2014 at 2:57 AM, Chris Angelico <rosuav at gmail.com> wrote:
>>
>> If you have a lengthy nested chain of coroutines, and one of them
>> unexpectedly raises StopIteration, is it right for something to
>> quietly terminate, or should the exception bubble up and be printed to
>> console?
>
>
> Couldn't you have a nested pile of iterator classes as well that would
> exhibit the exact same behavior?

Potentially, but that would be a different thing. Also, I don't know
of cases where a __next__ function chains to a next() call through
arbitrary numbers of levels, but :"yield from" gets a solid work-out
in asyncio and related, so it's more likely to come up. But I don't
personally use asyncio, so I'd like to hear from someone who does.

ChrisA


More information about the Python-ideas mailing list