美文网首页
python技巧-判断是否是其子类

python技巧-判断是否是其子类

作者: reallocing | 来源:发表于2018-10-24 13:05 被阅读0次
    # 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
    

    相关文章

      网友评论

          本文标题:python技巧-判断是否是其子类

          本文链接:https://www.haomeiwen.com/subject/xzwttqtx.html