|
发表于 2025-8-20 17:33:47
|
显示全部楼层
class A:
def __init__(self, *args, **kwargs): # 添加万能参数接收
super().__init__(*args, **kwargs) # 透传给后续父类
print("FishA")
class B:
def __init__(self, *args, **kwargs): # 同理
super().__init__(*args, **kwargs)
print("FishB")
class C(A):
def __init__(self, arg, *args, **kwargs):
super().__init__(*args, **kwargs) # 透传多余的参数
print("FishC")
class D(B):
def __init__(self, arg, *args, **kwargs):
super().__init__(*args, **kwargs)
print("FishD")
class E(C, D):
def __init__(self, arg):
super().__init__(arg) # 只需传递一次参数
print("FishE")
e = E(520) |
|