[Python-ideas] Preserving **kwargs order

Greg Ewing greg.ewing at canterbury.ac.nz
Thu Mar 20 22:34:59 CET 2014


MRAB wrote:
> It looks like the dict 'kwargs' is being passed straight to 'wrappee'.

But the interpreter doesn't just pass the object
given as a ** argument straight to the function's
** parameter; it gets repacked into a new dict:

 >>> def f(**kw):
...  print id(kw)
...
 >>> d = {'a':1, 'b':2}
 >>> print id(d)
2816160
 >>> f(**d)
2817744

So even if you pass an OrderedDict or some other
custom object as a ** argument, it's a plain dict
by the time it comes out the other end.

-- 
Greg


More information about the Python-ideas mailing list