What is the purpose of checking self.__class__ ? - python

后端 未结 5 951
伪装坚强ぢ
伪装坚强ぢ 2020-12-13 14:04

What is the purpose of checking self.__class__ ? I\'ve found some code that creates an abstract interface class and then checks whether its self.__class__

5条回答
  •  悲&欢浪女
    2020-12-13 14:47

    What is the purpose of that? Is it to check whether the class is a type of itself?

    Yes, if you try to construct an object of type Abstract1 it'll throw that exception telling you that you're not allowed to do so.

提交回复
热议问题