[Python-ideas] x=(yield from) confusion [was:Yet another alternative name for yield-from]
Greg Ewing
greg.ewing at canterbury.ac.nz
Sun Apr 5 01:27:00 CEST 2009
Guido van Rossum wrote:
> how important this use case really is (it's easily
> solved with a class, for example).
Yes, it's my feeling that a class would be better for
this kind of thing too.
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 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.
--
Greg
More information about the Python-ideas
mailing list