class A:
def method1(self):
print "this is the method1 of class A"
class B:
def method1(self):
print "this is the method2 of class B"
class C(A,B): #class C inherit from A and B
pass
c=C()
c.method1()#Now the question is which method will be call,A or B
#The result is:
this is the method1 of class A
That means,the inheritance rest with which super class in the starting location,in this example,class A in the zero position,so the method1 in class A will be call instead of class B
No comments:
Post a Comment