class A(object):
def __init__(self):
print 'Enter A'
print 'Leave A'
pass
def myprint(self):
print 'Enter print of A'
print 'Leave print of A'
def myecho(self):
print 'In echo of A'
class B(A):
def __init__(self):
print "Enter B"
super(B, self).__init__()
print "Leave B"
def myprint(self):
print 'Enter print of B'
super(B, self).myprint()
print 'Leave print of B'
class C(A):
def __init__(self):
print 'Enter C'
print 'Leave C'
def myprint(self):
print 'In print of C'
print '-------------------------------'
b = B()
print '-------------------------------'
b.myprint()
print '-------------------------------'
c = C()
c.myprint()
c.myecho()
print '-------------------------------'
a = A()
a.myprint()
a.myecho()
输出结果:
-------------------------------
Enter B
Enter A
Leave A
Leave B
-------------------------------
Enter print of B
Enter print of A
Leave print of A
Leave print of B
-------------------------------
Enter C
Leave C
In print of C
In echo of A
-------------------------------
Enter A
Leave A
Enter print of A
Leave print of A
In echo of A
阅读(4863) | 评论(0) | 转发(0) |