首页 > 编程语言 > 详细

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

时间:2019-06-25 13:04:54      阅读:98      评论:0      收藏:0      [点我收藏+]
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)

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

原文:https://www.cnblogs.com/lianghong881018/p/11081915.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!