What you want is in general not possible, because of the use of varargs and kwargs, but inspect.getargspec
(Python 2.x) and inspect.getfullargspec
(Python 3.x) come close.
Python 2.x:
>>> import inspect
>>> def add(a, b=0):
... return a + b
...
>>> inspect.getargspec(add)
(['a', 'b'], None, None, (0,))
>>> len(inspect.getargspec(add)[0])
2
Python 3.x:
>>> import inspect
>>> def add(a, b=0):
... return a + b
...
>>> inspect.getfullargspec(add)
FullArgSpec(args=['a', 'b'], varargs=None, varkw=None, defaults=(0,), kwonlyargs=[], kwonlydefaults=None, annotations={})
>>> len(inspect.getfullargspec(add).args)
2