super(type[, object-or-type])
Return the superclass of type. If the second argument is omitted the super object
returned is unbound. If the second argument is an object, isinstance(obj, type)
must be true. If the second argument is a type, issubclass(type2, type) must be
true. super() only works for new-style classes.
A typical use for calling a cooperative superclass method is:
class C(B):
def meth(self, arg):
super(C, self).meth(arg)
New in version 2.2.
返回超类的类型,如果第2个参数被忽略,父类返回时没有被绑定的
class C(B):
def meth(self, arg):
super(C, self).meth(arg)
class B(object):
def fun1(self,a):
return a + 10
class C(B):
def fun2(self,b):
return super(C,self).fun1(b) + 3
a=B()
print a.fun1(44)
c=C()
print c.fun2(33)
print c.fun1(55)
C:\Python27\python.exe C:/Users/TLCB/PycharmProjects/untitled2/socket/fun20.py
54
46
65