[Python-ideas] PEP 380 alternative: A yielding function

Greg Ewing greg.ewing at canterbury.ac.nz
Wed Jul 28 03:19:12 CEST 2010


Anders J. Munch wrote:

> But suppose you could address the source instead?  Suppose you could
> write yield_if_true in such a way that it did not become a generator
> despite yielding?

I don't see how this would work. The problem isn't that
yield_if_true becomes a generator -- it's that the function
calling yield_if_true *doesn't* become a generator, even
though it needs to.

> Let's call it 'yield_' , for lack of a
> better name.  The function would yield the nearest generator on the
> call stack.

But if none of the calling functions have yields anywhere
else, then they're just ordinary functions, and there is
*no* generator on the call stack!

-- 
Greg



More information about the Python-ideas mailing list