如果您通过getattr()
检索了某个属性,那么如何检查:
答案 0 :(得分:1)
In [50]: class Foo:
def __init__(self):
self.a = 4
def somefunc(self, x, y):
self.a = x+y
....:
In [51]: type(getattr(Foo, 'somefunc'))
Out[51]: function
In [52]: getattr(Foo, 'somefunc').__code__.co_argcount
Out[52]: 3