My application is this:
- I have an executor function that needs to execute some code based on a switch that is sent as an argument. It retains references to multiple functions and selects the needed function based on the switch. The thing is that these functions have different no. of params.
e.g.
class Execute:
def func1(self, f1_arg):
print("f1_arg", f1_arg)
def func2(self, f2_arg1, f2_arg2):
print("arguments: %s and %s" % (f2_arg1, f2_arg2))
def executor(self, sw):
available_functions = {
"sw1": self.func1,
"sw2": self.func2
}
predefined_arguments = {
"sw1": "f1_argument",
"sw2": ("f2_argument1", "f2_argument2")
}
# this is pseudo code, I have no idea how to do it
available_functions[sw](predefined_arguments[sw])