为什么我在Python代码中看不到以下内容?
class A:
def __init__(self, ...):
# something important
class B(A):
__init__ = A.__init__
Run Code Online (Sandbox Code Playgroud)
它似乎在我的盒子上使用Python 2.5,2.6,2.7和PyPy 1.8.
相反,我看到以下内容:
class B(A):
def __init__(self, *args, **kwargs):
A.__init__(self, *args, **kwargs)
Run Code Online (Sandbox Code Playgroud)
或使用的东西super.
我更喜欢我的第一个例子(明确比隐含更好!)但我担心它不是出于某种原因而变得犹豫不决.这有什么不对吗?
编辑:是的,我的意思是A.__init__,不是self.__init__
python ×1