I have different functions, but each takes different number of arguments and different arguments. I want to be able to execute only one of them and to do this based on the name of the function as string. I tried this:
def execute_function(function_name, arg1, arg2, arg3):
return {
'func1': func1(arg1),
'func2': func2(arg1, arg3),
'func3': func3(arg2),
}[function_name]
but it executes all functions :( no matter what is the string function_name
.
Do you have any ideas why this happens and how to achieve what I want. (I'm new to Python). Thank you very much in advance! :)