[Python-ideas] Possible PEP 380 tweak

Greg Ewing greg.ewing at canterbury.ac.nz
Sat Oct 30 01:30:54 CEST 2010


Guido van Rossum wrote:

> I went over that myself in detail and ended up deciding that for
> "yield-from" nothing should be changed! The expansion in the PEP
> remains the same.

In that case, the proposal has nothing to do with PEP 380
and needn't be mentioned in it -- except perhaps to point
out that using it in the presence of yield-from may
not produce the expected result.

> But since this PEP also specifies "return value" it would be nice if
> there was a convenient way to capture this value,

As long as you're willing to accept that if the generator
you're closing is delegating using yield-from, the return
value from the inner generator will get lost.

To put it another way, if you design a generator to be
used in this way (i.e. its caller using close() to finish
it and get a value), you may find it awkward or impossible
to later refactor it in certain ways.

-- 
Greg



More information about the Python-ideas mailing list