Neal Norwitz wrote:
> Ron Adam wrote: > >>Eval or exec aren't needed. Normally you would just do... >> >> execfunc['key1'](**args) >> >>If your arguments are stored ahead of time with your function... >> >> Committed revision 41366. Committed revision 41366 ? >>You could then do... >> >> func, args = execfunc['key1'] >> func(**args) > > > Interesting that both Ron and Alex made the same mistake. Hmmm, makes > me wonder if they are two people or not... > > If args is a tuple, it should be: > > func(*args) No mistake at all, I simply reused the name the OP used in his example. >>> execfunc = { 'key1' : func1(**args) } There's no rule that says you can't name a dictionary 'args', and it wasn't part of the posters question. > If you want the full generality and use keyword args: > > func(*args, **kwargs) I tend to prefer (*args, **kwds) myself. There are also times when I don't want full generality. In many cases the less general your arguments are to a function the easier it is to catch errors. Cheers, Ron -- http://mail.python.org/mailman/listinfo/python-list