[Python-ideas] x=(yield from) confusion [was:Yet another alternative name for yield-from]
Guido van Rossum
guido at python.org
Sun Apr 5 18:43:26 CEST 2009
On Sat, Apr 4, 2009 at 4:27 PM, Greg Ewing <greg.ewing at canterbury.ac.nz> wrote:
> Let's not lose sight of the fundamental motivation
> for all this, the way I see it at least: yield-from is
> primarily to permit factoring of generator code. Any
> proposals for enhancements or extensions ought to be
> justified in relation to that.
I still don't think that refactoring should drive the design
exclusively. Refactoring is *one* thing that becomes easier with
yield-from. But I want the design to look pretty from as many angles
>> I don't believe that once the generator has raised StopIteration or
>> ReturnFromGenerator, the return value should be saved somewhere to be
>> retrieved with an explicit close() call -- I want to be able to free
>> all resources once the generator frame is dead.
> I agree with that.
> As a corollary, I *don't* think that close() should
> return the value of a ReturnFromGenerator even if it
> gets one, because unless the value is stored, you'll
> only get it the first time close() is called, and
> only if the generator has not already completed
> normally. That would make it too unreliable for any
> practical use as far as I can see.
Throwing in GeneratorExit and catching the ReturnFromGenerator
exception would have the same problem though, so I'm not sure I buy
--Guido van Rossum (home page: http://www.python.org/~guido/)
More information about the Python-ideas