[Python-ideas] Preserving **kwargs order
MRAB
python at mrabarnett.plus.com
Thu Mar 20 03:42:54 CET 2014
On 2014-03-20 01:58, Andrew Barnert wrote:> On Mar 19, 2014, at 16:32,
Eric Snow <ericsnowcurrently at gmail.com> wrote:
>
>> Hopefully I'll have time to write a proto-PEP on this in the next
>> couple weeks, but the gist is that I see 2 options:
>
> Last time around, someone suggested that ***kwargs could get you the
> args as a list of pairs, or maybe an OrderedDict. While that would
> require a bit of complexity in the CALL_FUNCTION code, it seems like
> it would be simpler than your option 2.
>
> But it doesn't solve the main problem. Right now, you can forward
> any arguments perfectly by doing this:
>
> def wrapper(*args, **kwargs):
> return wrappee(*args, **kwargs)
>
> Your option 2 would require much more verbose code to forward
> perfectly. The triple-star idea makes it a lot nicer (assuming that
> ** passing respects the order, or a new *** is added there as well),
> but it would still break the thousands of wrapper functions out
> there written with **kwargs.
>
Wouldn't it be a problem only if the dict were unpacked and then
repacked? In the code above, it's merely passing the input kwargs on to
'wrappee'.
More information about the Python-ideas
mailing list