python技巧-判断是否是其子类
2018-10-24 本文已影响0人
reallocing
# You can check for class
# inheritance relationships
# with the "issubclass()" built-in:
>>> class BaseClass: pass
>>> class SubClass(BaseClass): pass
>>> issubclass(SubClass, BaseClass)
True
>>> issubclass(SubClass, object)
True
>>> issubclass(BaseClass, SubClass)
False