1个回答
展开全部
# -*- coding:utf-8 -*-
class FooParent(object):
def __init__(self):
self.parent = "I \'m the parent."
print "Parent"
def bar(self, message):
print message, "from Parent"
class Foochild(FooParent):
def __init__(self):
FooParent.__init__(self)
print "Child"
def bar(self, message):
FooParent.bar(self, message)
print "Child bar function."
print self.parent
if __name__ == '__main__':
foochild = Foochild()
foochild.bar("Hello word!")
if __name__ == '__main__':
这个应该定义写在整个模块中,移出来就可以了
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询