Getting the class name of an instance?

前端 未结 10 2259
情书的邮戳
情书的邮戳 2020-11-22 13:38

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 h

10条回答
  •  独厮守ぢ
    2020-11-22 14:08

    To get instance classname:

    type(instance).__name__
    

    or

    instance.__class__.__name__
    

    both are the same

提交回复
热议问题