keyword arguments and **

Boudewijn Rempt boud at valdyas.org
Fri Nov 15 09:51:32 EST 2002


I feel right silly, but for the life of I don't understand why
the variables I pass to f as named arguments stay remembered:

>>> def f(fields={}, **args):
...     print fields
...     fields.update(args)
...     print "XXX", fields
... 
>>> f(a=1)
{}
XXX {'a': 1}
>>> f(a=1)
{'a': 1}
XXX {'a': 1}
>>> f(b=1)
{'a': 1}
XXX {'a': 1, 'b': 1}
>>> 


-- 
Boudewijn Rempt | http://www.valdyas.org



More information about the Python-list mailing list