Re: Dynamic function execution

2006-11-26 Thread Fredrik Lundh
Cameron Laird wrote: > ? Or am I missing the point that a better example of what > Mr. Wu really wants is > > def func(seconds = None, minutes = None, hours = None): > print seconds > print minutes > print hours > > dimension = "minutes" > func(**{dimension: 30}) I ass

Re: Dynamic function execution

2006-11-25 Thread John Machin
Cameron Laird wrote: > In article <[EMAIL PROTECTED]>, > Fredrik Lundh <[EMAIL PROTECTED]> wrote: > >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 p

Re: Dynamic function execution

2006-11-25 Thread Cameron Laird
In article <[EMAIL PROTECTED]>, Fredrik Lundh <[EMAIL PROTECTED]> wrote: >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'

Re: Dynamic function execution

2006-11-25 Thread Irmen de Jong
Andy Wu wrote: > 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? d={"minutes": 30} func(**d) This is "extended call syntax". You can read more about this when you look up the (deprecated) "apply" function in the manual.

Re: Dynamic function execution

2006-11-25 Thread Fredrik Lundh
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 integ

Dynamic function execution

2006-11-25 Thread Andy Wu
Hi guys, There's a function I want to use which looks like this: 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