How to check whether it is always possible to call a function with the same arguments as another function? For example, you can call with all the arguments provided . b a
def a(a, b, c=None):
pass
def b(a, *args, d=4,**kwargs):
pass
I want to have a basic function:
def f(a, b):
print('f', a, b)
and callback list:
def g(b, a):
print('g', a, b)
def h(*args, **kwargs):
print('h', args, kwargs)
funcs = [g, h]
and a wrapper function that accepts something:
def call(*args, **kwargs):
f(*args, **kwargs)
for func in funcs:
func(*args, **kwargs)
Now I want to check if all callbacks will accept the arguments provided call()if they are valid for f(). For performance reasons, I don’t want to check the arguments every time I call call(), but check every callback before adding it to the callback list. For example, these calls are in order:
call(1, 2)
call(a=1, b=3)
, g :
call(1, b=3)