码迷,mamicode.com
首页 > 编程语言 > 详细

Python中的多重继承

时间:2021-02-23 14:00:02      阅读:0      评论:0      收藏:0      [点我收藏+]

标签:优先   广度优先   继承   pass   print   class   python   python3   查看   

class P1:
    pass


class P2:
    pass


class P3:
    pass


class A(P1, P2):
    pass


class B(P1, P3):
    pass


class C(P3, P2):
    pass


class D(A, B, C):
    pass


d = D()
print(D.__mro__)
# 查看 D类的多重继承的搜索顺序: D.__mro__
#python3中都是新式类,遵循的搜索原则是 广度优先

结果

(<class ‘__main__.D‘>, <class ‘__main__.A‘>, <class ‘__main__.B‘>, <class ‘__main__.P1‘>, <class ‘__main__.C‘>, <class ‘__main__.P3‘>, <class ‘__main__.P2‘>, <class ‘object‘>)

Python中的多重继承

标签:优先   广度优先   继承   pass   print   class   python   python3   查看   

原文地址:https://www.cnblogs.com/kevin1220/p/14427783.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!