>>> class A(object):
... def some(self):
... pass
...
>>> a=A()
>>> a.some
<bound method A.some of <__main__.A object at 0x7f0d6fb9c090>>
Run Code Online (Sandbox Code Playgroud)
IOW,我需要在仅仅移交"a.some"后才能访问"a".
我有一个函数,它将另一个函数作为参数.如果函数是类的成员,我需要找到该类的名称.例如
def analyser(testFunc):
print testFunc.__name__, 'belongs to the class, ...
Run Code Online (Sandbox Code Playgroud)
我想
testFunc.__class__
Run Code Online (Sandbox Code Playgroud)
会解决我的问题,但这只是告诉我testFunc是一个函数.