[Python-Dev] yield * (Re: Missing operator.call)

Greg Ewing greg.ewing at canterbury.ac.nz
Sat Feb 7 10:04:29 CET 2009


Guido van Rossum wrote:

> It would be way too confusing to have "a different form of call" with
> totally different semantics that nevertheless used the same
> *terminology* as is used for regular calls.

I expect you're right, so I won't argue for calling
it "call" any more.

I'd still like to find a good name for it, though.
The other important thing is that my proposed construct
should be usable as an expression, and its value
should be whatever is returned by the called generator
when it exits. E.g. if we continue spelling it
"yield *" for the moment, then

   def f():
     v = yield *g()
     print v

   def g():
     yield 42
     return "spam"

   for x in f():
     pass

should end up printing "spam".

Would you entertain the idea of a "yield *" expression
with those semantics?

-- 
Greg


More information about the Python-Dev mailing list