[Python-Dev] PEP 380 (yield from a subgenerator) comments

Guido van Rossum guido at python.org
Sun Mar 29 05:01:09 CEST 2009

On Sat, Mar 28, 2009 at 8:14 PM, Nick Coghlan <ncoghlan at gmail.com> wrote:
> Greg Ewing wrote:
>> Guido van Rossum wrote:
>>> But it's been answered already -- we can't change the meaning of
>>> StopIteration() with a value unequal to None, so it has to be a
>>> separate exception, and it should not derive from StopIteration.
>> How about having StopIteration be a subclass of the
>> new exception? Then things that want to get generator
>> return values only have one exception to catch, and
>> things that only know about StopIteration will fail
>> to catch the new exception.
> I actually like that, because it means that "coroutine-y" code could
> pretty much ignore the existence of StopIteration (despite it existing
> first).


> It would also mean that it wouldn't matter if "return" and "return None"
> both raised StopIteration, since they would still be intercepted by
> GeneratorReturn exception handlers.

Well I already didn't care about that. :-)

--Guido van Rossum (home page: http://www.python.org/~guido/)

More information about the Python-Dev mailing list