class Base:
def test(self):
print('---base----')
class A(Base):
def test(self):
print("---A----")
class B(Base):
def test(self):
print("---B----")
class C(A,B):
def test(self):
print("---C----")
super().test()
c = C()
c.test()
结果为:
---C----
---A----
但是:
class Base:
def test(self):
print('---base----')
class A(Base):
def test(self):
print("---A----")
super().test()
class B(Base):
def test(self):
print("---B----")
class C(A,B):
def test(self):
print("---C----")
super().test()
c = C()
c.test()
结果为:
---C----
---A----
---B----
这里的---B----是怎么出来的,不太明白,求高手指点一二!!
官方的python2.7和python3.6都不支持super()的语法,官方文档
super(type, obj) -> bound super object; requires isinstance(obj, type)
| super(type) -> unbound super object
| super(type, type2) -> bound super object; requires issubclass(type2, type)
| Typical use to call a cooperative superclass method:
请问你用的那款解释器