I have this function:
def func(a, b, c=1, d=2):
pass
With this:
import inspect
inspect.getargspec(func)
I get this result:
ArgSpec(args=['a', 'b', 'c', 'd'], varargs=None, keywords=None, defaults=(1, 2))
Is there an easier way to find the arguments of a function which do not take default values? With the statement above I have to do something ugly like this
ab = args[:-len(defaults)]
to retrieve those arguments. ab
will now be ['a', 'b']
Thanks.
[EDIT] For more clarifications:
I want to do this inspect outside the function func
, not inside it.