我是python的新手,但是我对二级继承有疑问。
我有这种情况:
class A:
def Something(self):
#Do Stuff
class B(A):
def SomethingElse(self):
#Do other stuff
class C(B):
def Something(self):
#Do additional stuff
请注意,类C继承自B,而类B继承自A,但类B不实现Something()方法。
如果我为类C的实例调用super(C,self).Something(),会发生什么?它会调用类A中的方法吗?
另外,如果类B确实实现Something(),但我想直接从类C调用类A的Something()(即绕过类B的实现),该怎么办?
最后,有人可以向我解释为什么人们使用super()而不是直接调用父类的方法吗?谢谢。
慕森卡
MMTTMM
相关分类