python 调用未绑定的超类构造方法

class Bird:
def __init__(self):
self.hungry = True

def eat(self):
if self.hungry:
print('Aaaaah')
self.hungry = False
else:
print('No. thanks')


class SongBird(Bird):
def __init__(self):
Bird.__init__(self)
self.sound = 'squawk'

def sing(self):
print(self.sound)


class SongBird(Bird):
def __init__(self):
super(SongBird, self).__init__()
self.sound = 'squawk'

def sing(self):
print(self.sound)
posted @ 2019-06-25 11:37  嵌入式实操  阅读(333)  评论(0编辑  收藏  举报