问题:
How do I find out a name of class that created an instance of an object in Python if the function I am doing this from is the base class of which the class of the instance has been derived? 若是我从中执行此操做的函数是实例的类派生的基类,如何找出在Python中建立对象实例的类的名称? html
Was thinking maybe the inspect module might have helped me out here, but it doesn't seem to give me what I want. 想到也许检查模块可能在这里帮助了我,但它彷佛没有给我我想要的东西。 And short of parsing the __class__
member, I'm not sure how to get at this information. 若是没有解析__class__
成员,我不知道如何获取这些信息。 python
解决方案:
参考一: https://stackoom.com/question/28vU/获取实例的类名参考二: https://oldbug.net/q/28vU/Getting-the-class-name-of-an-instance