[Python-ideas] return value of yield expressions

Matt Joiner anacrolix at gmail.com
Tue Sep 13 14:49:05 CEST 2011


I don't see any value in this. Please give an example where keyword
unpacking is clearly superior.
On Sep 13, 2011 10:42 PM, "Jacob Holm" <jh at improva.dk> wrote:
> Hi Stefan
>
> 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,
> **kwds) really.
>
>
>> Time machine keys are back were they were. Nothing to see here, keep
>> passing.
>
> I disagree. You overlooked most of the requested feature...
>
> - Jacob
> _______________________________________________
> Python-ideas mailing list
> Python-ideas at python.org
> http://mail.python.org/mailman/listinfo/python-ideas
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20110913/fe56f82e/attachment.html>


More information about the Python-ideas mailing list