Calling a function, arguments in a dict ??

Jp Calderone exarkun at intarweb.us
Mon Jun 23 01:36:52 CEST 2003


On Mon, Jun 23, 2003 at 12:19:24AM +0200, Thomas Weholt wrote:
> 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)

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

  Jp

-- 
"One World, one Web, one Program." - Microsoft(R) promotional ad
"Ein Volk, ein Reich, ein Fuhrer." - Adolf Hitler





More information about the Python-list mailing list