super multiple inheritance

 1 class Father():
 2     def __init__(self, name, house):
 3         self.name = name
 4         self.house = house
 5     def work(self):
 6         print("挣钱养家")
 7     def eat(self):
 8         print("Father -- 吃饭")
 9 class Mother():
10     def __init__(self, name, face):
11         self.name = name
12         self.face = face
13     def shopping(self):
14         print("貌美如花")
15     def eat(self):
16         print("Mother -- 吃饭")
17 
18 # 多继承   son -> mother -> father
19 class Son(Mother, Father):
20     def __init__(self, house, name, face, toy):
21         self.toy = toy
22         # Mother.__init__(self, name, face)
23         # Father.__init__(self, name, house)
24         super(Son, self).__init__(name, face)   # Mother
25         super(Mother, self).__init__(name, house)   # Father
26 
27 
28     def eat(self):
29         # Mother.eat(self)
30         # Father.eat(self)
31         print("son -- eat")
32 
33 son1 = Son("h", "N", "F", "T")
34 print(son1.toy)
35 print(son1.name)
36 print(son1.face)
37 print(son1.house)

 

Guess you like

Origin www.cnblogs.com/BKY88888888/p/11278788.html