samedi 16 janvier 2016

Is there a way to get function parameter names, including bound-methods excluding `self`?

I can use inspect.getargspec to get the parameter names of any function, including bound methods:

>>> import inspect
>>> class C(object):
...     def f(self, a, b):
...             pass
...
>>> c = C()
>>> inspect.getargspec(c.f)
ArgSpec(args=['self', 'a', 'b'], varargs=None, keywords=None, defaults=None)
>>>

However, getargspec includes self in the argument list.

Is there a universal way to get the parameter list of any function (and preferably, any callable at all), excluding self if it's a method?





Aucun commentaire:

Enregistrer un commentaire