I\'d like to find out the arity of a method in Python (the number of parameters that it receives). Right now I\'m doing this:
def arity(obj, method):
retur
Use a decorator to decorate methods e.g.
def arity(method):
def _arity():
return method.func_code.co_argcount - 1 # remove self
method.arity = _arity
return method
class Foo:
@arity
def bar(self, bla):
pass
print Foo().bar.arity()
Now implement _arity
function to calculate arg count based on your needs