**kwds behavior?
Terry Reedy
tjreedy at udel.edu
Tue Sep 2 15:52:35 EDT 2003
"Hans Nowak" <hans at zephyrfalcon.org> wrote in message
news:mailman.1062522376.29013.python-list at python.org...
> Now, on to the yucky solution:
>
> >>> def g(**kwargs):
> for key, value in kwargs.items():
> exec "%s = %s" % (key, repr(value))
> # test test...
This is cute but limited. It only works when values ==
eval(repr(value)), which is to say, numbers, strings, and,
recursively, tuples, lists, and dicts and some user-class instances.
Others will raise syntax error.
Terry J. Reedy
More information about the Python-list
mailing list