[Python-ideas] return value of yield expressions

H. Krishnan hetchkay at gmail.com
Tue Sep 13 15:00:59 CEST 2011


In the particular situation of send() --> yield, one could do something like 
(forgeting the backward compatibility with respect to the return value):

gen.send(2, a2=3, e=5)

and in the gen:
(a1, a2, a3 = 3, *args, **kwds) = (yield <expr>)

without having to do whatever Jacob has written:
args, kwds = (yield <expr>)
(a1, a2, a3, *args), kwds = (lambda a1,a2,a3=3,*args, **kwds:
                             (a1,a2,a3)+args, kwds
                            )(*args, **kwds)




-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20110913/045e2c04/attachment.html>


More information about the Python-ideas mailing list