旧式类:
class jiushi(): def __init__(self,a1): self.a=a1 class jiushi_son(jiushi): def __init__(self,a1): jiushi.__init__(self,a1)
新式类:(多继承时)
class xinshi(object): def __init__(self, a1): self.a = a1 class xinshi_son(xinshi): def __init__(self, a1): super(xinshi_son,self).__init__(a1)
查询策略:
a.广度优先:先横向,再向上一级
b.深度优先:先向上一级,再横向
python2 经典类按照深度优先继承,新式类按广度优先继承
python3 经典类和新式类都按照广度优先继承
原文地址:https://www.cnblogs.com/q1ang/p/9048776.html
时间: 2024-11-02 22:24:48