Calling a function, arguments in a dict ??

Dan Bishop danb_83 at yahoo.com
Mon Jun 23 00:11:09 EDT 2003


"Thomas Weholt" <2002 at weholt.org> wrote in message news:<wYpJa.8525$Hb.148440 at news4.e.nsc.no>...
> If I got a dictionary with a bunch of key/values I want to use as named
> arguments for a function, how do I do that?
> 
> Say we got a function a, takes three parameters; x,y,z. In my dictionary I
> got {'z': 1, 'x': 2, 'y': 3}. How can I create some code that will call it
> like this :
> 
> a(z =1, x=2, y=3)
> 
>  ???

kwargs = {'z':1, 'x':2, 'y':3}
a(**kwargs)




More information about the Python-list mailing list