Passing parameters using **kargs
Thomas Philips
tkpmep at hotmail.com
Mon Jun 7 22:58:07 EDT 2004
More information about the Python-list mailing list
Mon Jun 7 22:58:07 EDT 2004
- Previous message (by thread): Passing parameters using **kargs
- Next message (by thread): Passing parameters using **kargs
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
I want to access parameters that are passed into a function using the
**kargs idiom. I define f(**kargs) via
def f(**kargs):
print kargs
.
.
the keyword arguments are converted to a dictionary, so that if I type
f(a=1, b=2, c=3)
the function prints
{'a': 1, 'b': 2, 'c':3}
Now assume the function has three variables a, b and c to which I want
to assign the dictionary's values of 'a', 'b' and 'c'. How can I
assign kargs['a'] to a, kargs['b'] to b, and kargs['c'] to c. Should I
be trying to construct a string representation of each variable's name
and using that as a key, or am I just thinking about this the wrong
way?
Thomas Philips
- Previous message (by thread): Passing parameters using **kargs
- Next message (by thread): Passing parameters using **kargs
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list