I wondering if it is possible to pass functions with different number of arguments to another function in Python.
For example
def aux_1(arg1,arg2):
if arg1 > arg2: return 1
else: return 0
def aux_2(arg1,arg2,arg3):
return arg1 + arg2 * arg3
def Main_fn(function_to_use,arg1, arg2, arg3):
return function_to_use(?)
>>>Main_fn(aux_1,1,2,1) #Example cases
>>>Main_fn(aux_2,1,2,1)
So this is my doubt, if I pass function aux_1 how could I ensure it uses only arg1 and arg2. Similarly, if I use aux_2 all the three arguments need to used.
I know it is possible to use a set of if conditions in the Main_fn, using inspect.getargspec()/varargs to appropriately pass on the arguments. However, such a logic would require modifications to the Main_fn each time I make a new aux function to handle its arguments, which is not practical in a large development scenario.
Hence, I'm looking for a way around this.
Please feel free to question me, if in need of further clarifications.