Dynamic function execution

Fredrik Lundh fredrik at pythonware.com
Sat Nov 25 10:47:45 EST 2006


Andy Wu wrote:

> def func(seconds = None, minutes = None, hours = None):
>     ...
> 
> In my program I can get a string object('seconds', 'minutes', 'hours')
> to specify which parameter to use, the problem is I don't know how to
> call the function.
> 
> Say I have a string 'minutes' and a integer 30, now I need to call the
> func this way: func(minutes = 30), how do I do this?

    func(**{"minutes": 30})

</F>




More information about the Python-list mailing list