[Python-ideas] return value of yield expressions
hetchkay at gmail.com
Tue Sep 13 19:04:57 CEST 2011
> Consider this example:
> def foo():
> *(a, b) = yield
> f = foo()
> f.send(1, 2) # Ok
> def wrapper(g):
> r = next(g)
> while 1:
> args = (yield r)
> r = g.send(args) # BOOM!
> f = wrapper(foo())
> f.send(1, 2) # BOOM!
> That wrapper works today, and does nothing (except messing up throw
> handling, but that is a different story). With your suggested change,
> such a wrapper would break unless it was changed to use
> *(*args, **kwargs) = (yield r)
> instead. IOW a backwards incompatible change.
I still don't get it. f.send(1, 2) is not allowed now. The wrapper will
still work for send() with single argument and so there is no backward
compatibility issue. The wrapper itself could be updated to support multiple
arguments to send if and when it is allowed.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Python-ideas