Calling a function, arguments in a dict ??

Tom Hanks thanks200 at
Mon Jun 23 05:44:44 CEST 2003

"Thomas Weholt" <2002 at> wrote in message news:<wYpJa.8525$Hb.148440 at>...
> 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?

The 'apply' builtin function is designed to handle this.

>>> argDict = {'num':10, 'dom':2}
>>> def ratio(num, dom):
... 	return num/dom
>>> apply(ratio, [], argDict)

Tom Hanks.

More information about the Python-list mailing list