(I really can’t come up with a better title!)
I’ve got a set of functions:
def foo(bar, baz)
def spam(blah, etc, woof)
and a Namespace object which includes the function name and function-specific params, e.g. args=(fun=foo, baz=111, baz=222). How do I call the function and pass params to it? Like this, but nicer:
x = vars(args)
fun = x['fun']
del x['fun']
fun(**x)
(I’m looking for a nice one-line solution).
When
aDictis a dictionary with function name under"fun"key and other arguments you could try:aDict.pop("fun")(**aDict)