可能重复:
Python 3 super() 的使用
在 Python 3.2 的文档中它说;
如果省略第二个参数,则返回的超级对象是未绑定的
据我了解,未绑定(如“未绑定到实例”)对象是从超(类,类)返回的。那么,超(类)中的“未绑定”是什么意思?你怎么绑定它?
class Base:
def printme(self): print("I'm base")
class Derived(Base):
def printme(self): print("I'm derived")
class Derived2(Derived):
def printme(self):
super().printme()
# next-in-mro bound-to-self method
super(Derived, self).printme()
# beyond-Derived-in-mro bound-to-self method
super(Derived, Derived2).printme(self)
# beyond-Derived-in-mro-of-Derived2 unbound method
super(Derived2).printme
# WTF is this? There's not even a printme attribute in it
Derived2().printme()