In Python, how can you get the name of a member function's class?

后端 未结 5 485
小鲜肉
小鲜肉 2020-12-28 08:01

I have a function that takes another function as a parameter. If the function is a member of a class, I need to find the name of that class. E.g.

def analyse         


        
5条回答
  •  一个人的身影
    2020-12-28 08:42

    testFunc.im_class
    

    https://docs.python.org/reference/datamodel.html#the-standard-type-hierarchy

    im_class is the class of im_self for bound methods or the class that asked for the method for unbound methods

提交回复
热议问题