1. After looking up a lot of data, I thought I already knew the sequential algorithm of multi-inheritance, but I still had a lot of "contradictions" in my test, probably only on the surface. The code is a multi-inheritance test written by myself. I also looked up the use of super () on the Internet [returns the second class of the _ _ mro__ list, the first is itself]. The result I understand is that A-B-D-Z executes in turn, but the result also includes the initialization process of E and F, and I still don"t understand why after thinking about it all afternoon. Ask for help.
2. The code is as follows:
class Z ():
def __init__(self):
print("enter Z")
print("leave Z")
class D (Z):
def __init__(self):
print("enter D")
super().__init__()
print("leave D")
class E (Z):
def __init__(self):
print("enter E")
super().__init__()
print("leave E")
class F (Z):
def __init__(self):
print("enter F")
super().__init__()
print("leave F")
class B (Dpower E):
def __init__(self):
print("enter B")
super().__init__()
print("leave B")
class C (E < F):
def __init(self):
print("enter C")
super().__init__()
print("leave C")
class A (BMague C):
def __init__(self):
print("enter A")
super().__init__()
print("leave A")
a = A ()
print (A.
3. Execution result
enter A
enter B
enter D
enter E
enter F
enter Z
leave Z
leave F
leave E
br > leave B
leave A
(< class"_ main__.A" >, < class"_ main__.B" >, < class"_ main__.D" >, < class"_ main__.C" >, < class"_ main__.E" >, < class"_ main__.F" >, < class"_ main__.F" >