我在Python面向对象的编程方面非常新颖,而且我很难理解super()函数(新样式类),特别是在涉及到多重继承时。
例如,如果你有像这样的东西:
class First(object):
def __init__(self):
print "first"
class Second(object):
def __init__(self):
print "second"
class Third(First, Second):
def __init__(self):
super(Third, self).__init__()
print "that's it"
我没有得到的是:Third()类会继承两个构造方法?如果是的话,那么哪一个会用super()运行,为什么呢?
而如果你想运行另一个呢?我知道这与Python方法解析顺序(MRO)有关。
相似问题