class A(object):
def __init__(self):
self.a = 1
def x(self):
print "A.x"
def y(self):
print "A.y"
def z(self):
print "A.z"
class B(A):
def __init__(self):
A.__init__(self)
self.a = 2
self.b = 3
def y(self):
print "B.y"
def z(self):
print "B.z"
class C(object):
def __init__(self):
self.a = 4
self.c = 5
def y(self):
print "C.y"
def z(self):
print "C.z"
class D(C,B):
def __init__(self):
C.__init__(self)
B.__init__(self)
self.d = 6
def z(self):
print "D.z"
obj = D()
print obj.a
obj.y()这个代码class D(C,B)中的B和C调换位置obj.a print出来永远是2,而obj.y()会随着位置调换改变输出值感觉这既不符合深度优先也不符合广度优先?这是什么鬼??
添加回答
举报
0/150
提交
取消