Calling a function, arguments in a dict ??

Jp Calderone exarkun at intarweb.us
Sun Jun 22 19:36:52 EDT 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