4
類B
子類A
,所以在B的__init__
我們應該叫A的__init__
這樣的:
class B(A):
def __init__(self):
A.__init__(self)
但與super()
,我看到了這樣的事情:
class B(A):
def __init__(self):
super(B, self).__init__() #or super().__init__()
我的問題是:
爲什麼不
super(B, self).__init__(self)
?僅僅因爲返回代理對象是綁定的對象?如果我在super中省略第二個參數並且返回代理對象是未綁定的,那麼我應該寫
super(B).__init__(self)
?
許多許多人 - 請先搜索。 [如何做,蟒蛇,超級做正確的事情](http://stackoverflow.com/questions/607186/how-does-pythons-super-do-the-right-thing)[怎麼做-python-3-python-3-python-3-python-3-python-3-python-3-python-3-python-3-python-3-python-3-python-3 -super](http://stackoverflow.com/questions/2771904/usage-of-python-3-super) – agf