Let's say I have a function in Python:
def foo(x,a=".",b=2):
...
and I have a dictionary:
param_dict = {'a':'!', 'b':5}
How would I be able to communicate the values in param_dict
to foo
, matching the corresponding dictionary key to the argument name, and do so in an automatic way? (i.e., not manually writing out foo(x,a=param_dict['a'],b=param_dict['b'])
)
Also would like it so that if the corresponding key isn't found in param_dict
, the default value of the argument is kept.