[Python-ideas] return value of yield expressions
jh at improva.dk
Tue Sep 13 14:32:01 CEST 2011
On 2011-09-13 14:21, Stefan Behnel wrote:
> Jacob Holm, 13.09.2011 13:02:
>> args, kwds = (yield ret) # any expression really
>> (a1, a2, a3, *args), kwds = (lambda a1,a2,a3=default,*args, **kwds:
>> (a1,a2,a3)+args, kwds
>> )(*args, **kwds)
> Note that recent Python versions support extended argument unpacking, so
> this works:
> a1, *other, a2 = return_some_sequence()
If you look closer you'll see I am actually using that feature already
in the code snippet you quoted.
> If you use the last value of the returned sequence (such as a tuple) to
> pass a dict, or if you return a tuple with two arguments (posargs,
> kwargdict), you basically get what you wanted above.
basically no. The suggested "function argument unpacking" includes
support for default values, and for passing positional arguments by
name. Everything that happens when you call a function using (*arg,
> Time machine keys are back were they were. Nothing to see here, keep
I disagree. You overlooked most of the requested feature...
More information about the Python-ideas