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

Nick Coghlan ncoghlan at gmail.com
Thu Mar 26 05:51:08 CET 2009

Guido van Rossum wrote:
> On Wed, Mar 25, 2009 at 6:22 AM, Nick Coghlan <ncoghlan at gmail.com> wrote:
>> It could perhaps be done by enhancing the part of the
>>> 'for' loop that gets executed upon normal termination
>>> of the iterator.
>>>   for x in my_iter:
>>>     do_something_with(x)
>>>   else v:
>>>     handle_return_value(v)
>> I think something like that would actually make the PEP much stronger on
>> this front - it would promote the idea of a "final value" for iterators
>> as a more fundamental concept that can be worked with in a non-generator
>> context.
> Hold it right there. Or maybe I should say "in your dreams." Please
> don't stretch the scope of the PEP. It's not going to help your cause.

Yes, I now agree your suggestion of comparing and contrasting with PJE's
simple trampoline example is a much better angle of attack.

Although the PEP may still want to mention how one would write *tests*
for these things. Will the test drivers themselves need to be generators
participating in some kind of trampoline setup?


Nick Coghlan   |   ncoghlan at gmail.com   |   Brisbane, Australia

More information about the Python-Dev mailing list