【发布时间】:2022-01-09 08:40:19
【问题描述】:
这段代码:
class a:
def __init__(self):
print("a here")
class b(a):
def __init__(self):
print("b here")
super().__init__()
B = b()
class a:
def __init__(self):
print("NEW a here")
BB = b()
产生这个输出:
b here
a here
b here
a here
为什么?
如果我将 b 类中的 super().init() 更改为 a.init(self),它可以正常工作。
【问题讨论】:
标签: python-3.x class redefinition