variable arguments question
Roel Schroeven
rschroev_nospam_ml at fastmail.fm
Tue Mar 15 03:11:12 EST 2005
vegetax wrote:
> if i have a dictionary:
> d = {'a':2,'b':3 }
> l = (1,2)
>
> how can i pass it to a generic function that takes variable keywords as
> arguments? same thing with variable arguments, i need to pass a list of
> arguments to the function
>
> def asd(**kw): print kw
> def efg(*arg): print arg
>
> i need to pass those as a dictionary and a list,since i dont know ahead of
> time if which items would have d and l
You can call them with a syntax resembling the way you defined them:
>>> asd(**d)
{'a': 2, 'b': 3}
>>> efg(*l)
(1, 2)
--
If I have been able to see further, it was only because I stood
on the shoulders of giants. -- Isaac Newton
Roel Schroeven
More information about the Python-list
mailing list