Is there a way to check a function's signature in Python?
You can use:
import inspect
len(inspect.getargspec(foo_func)[0])
This won't acknowledge variable-length parameters, like:
def foo(a, b, *args, **kwargs):
pass
You should use inspect.getargspec
.
inspect.getargspec
is deprecated in Python 3. Consider something like:
import inspect
len(inspect.signature(foo_func).parameters)