This question is merely out of curiosity. Let's say I have the two functions below.
def func_1(a, b):
return a + b
def func_2(a, b, c):
return a + b + c
Then I get three ints from the user. Is there a way to do something like this?
if <func_1 accepts a, b, and c>:
print(func_1(a, b, c)
else:
print(func_2(a, b, c)
I know about *args, **kwargs, and try/except clause, and I know there are other ways to get around this. The reason this came to my mind is that some packages like huggingface evaluate currently have a bug where they can't run some metrics together because if they pass the content of **kwargs to the metrics' functions one of them will raise unexpected keyword errors while others are expecting the arguments or don't care about them. Furthermore, the number of metrics are just too many to implement except clauses not to mention how expensive traceback generation is. So, I thought if there was a way to loop and add arguments when needed without trying/except the problem will be solved. I played around with partial
from functools
but it does not evaluate the function before it is invoked. Hence, the question. Does anyone know of a way?