[Python-ideas] Alternative name for yield-from
Guido van Rossum
guido at python.org
Wed Feb 18 22:16:48 CET 2009
On Wed, Feb 18, 2009 at 12:22 PM, Greg Ewing
<greg.ewing at canterbury.ac.nz> wrote:
> I've had another idea about what to call yield-from:
> y = pass g(x)
> which means "run this generator, passing through
> any sent/yielded values etc." It's short, it's
> suggestive, it doesn't use any new keywords, and
> there's no danger of confusing it with 'yield'.
> Now, you're probably reaching for the -1 button
> at this point, thinking "WTF? That's completely
> different from the existing meaning of pass!"
> But there's a sense in which the existing 'pass'
> can be seen as a degenerate case. Consider the
> def nada():
> if False:
> Since it never yields anything, doing
> pass nada()
> is effectively a no-op. Thus, 'pass' with no
> generator at all is a no-op as well.
> There's still one remaining difference -- the
> presence of 'pass' with a value would make the
> containing function into a generator, whereas
> plain 'pass' wouldn't. We'd just have to live
> with that inconsistency.
-1000 because of that last one.
--Guido van Rossum (home page: http://www.python.org/~guido/)
More information about the Python-ideas