How do I check (at runtime) if one class is a subclass of another?

前端 未结 9 1789
忘了有多久
忘了有多久 2020-11-28 05:40

Let\'s say that I have a class Suit and four subclasses of suit: Heart, Spade, Diamond, Club.

class Suit:
   ...
class Heart(Suit):
   ...
class Spade(Suit):         


        
9条回答
  •  星月不相逢
    2020-11-28 05:51

    issubclass(class, classinfo)

    Excerpt:

    Return true if class is a subclass (direct, indirect or virtual) of classinfo.

提交回复
热议问题