super函数主要为了调用超类的方法
__metaclass__=type
class Bird():
def __init__(self):
self.hungry=True
def eat(self):
if self.hungry:
print 'Ahah'
self.hungry=False
else:
print 'No,thanks'
class SongBird(Bird):
def __init__(self):
super(Bird,self).__init__()
self.sound='Squark'
def sing(self):
print self.sound
—>a=SongBird()
—>a.sing()
Squawk!