I've been looking for a while and I haven't found anything similar to what I'm looking for. I want to be able to pass varying parameters to a function that is already defined in an API.
For example, I get a list of args from my CLI, some of which are optional. I want to pass all the given args to this function. The function in the API is accepting the args with **kwargs (and an additional arg that is required).
Right now I have a dictionary of the args and I somehow need to pass them to the function in the form of func_name(param1=val1, param2=val2)
and so on. I have no idea how to convert my dictionary (that looks like {'param1':val1, 'param2':val2}
) into the format for the function.
There must be a nicer way to do this than to write out a separate if statement for every possible scenario. Thanks in advance for your help!
TL;DR:
How can I pass values from a dictionary like {'param1':val1, 'param2':val2}
into a function call like func_name(param1=val1, param2=val2)
?