我有一个函数,需要另一个函数作为参数。如果该函数是类的成员,则需要找到该类的名称。例如。
def analyser(testFunc):
print testFunc.__name__, 'belongs to the class, ...
我想
testFunc.__class__
可以解决我的问题,但这只是告诉我testFunc是一个函数。
最佳答案
testFunc.im_class
https://docs.python.org/reference/datamodel.html#the-standard-type-hierarchy