# -*- coding:utf-8 _*-
"""
@author:Administrator
@file: yamlparser.py
@time: 2018/09/07
"""
class A(object):
"""
Method resolution order是python用来解析方法调用顺序的。
MRO对于多重继承中方法调用异常重要。python中有一个内建函
数和MRO密切相关——super.super不是简单地调用所谓基类的方法,
而是调用MRO中的下一个类的方法,也就是类似于next的方法。
"""
def __init__(self):
print("A")
super(A, self).__init__() # --D
class B(object):
def __init__(self):
print("B")
super(B, self).__init__()
class C(A):
def __init__(self, *args):
print("c", "arg=", args)
super(C, self).__init__() # --A
class D(B):
def __init__(self, *args):
print("D", "arg=", args)
super(D, self).__init__()
class E(C, D):
def __init__(self, *args,**kwargs):
print("E", "arg=", args)
super(E, self).__init__(*args,**kwargs) # E -->C
print("MRO", [x.__name__ for x in E.__mro__])
E(10)