python super和继承的关系, 继承顺序

class Base(object):
def init(self):
print 'Base create'

class childA(Base):
def init(self):
print 'creat A ',
Base.init(self)

class childB(Base):
def init(self):
print 'creat B ',
super(childB, self).init() # 此处childB,是super从childB继承关系的上一级开始

super().init() 是继承 继承顺序的下一个类的初始化,新式类(继承自object的类)才可以用

类继承顺序看这篇文章 https://www.cnblogs.com/wujiaqing/p/10861026.html


https://mp.weixin.qq.com/s/pXli7m7tJgSBlX5LvYfEcg

posted @ 2021-07-15 17:01  nonamehhhhh  阅读(72)  评论(0)    收藏  举报