我是python的初学者......我写了这段代码期望输出为,
global name:xxx
derived class
base class
globally declared function has been called
globally declared function has been called
但我得到以下输出,
Global name:xxx
derived class
derived class
base class
None
Globally declared function has been called
Globally declared function has been called
其实逻辑是什么?我哪里错了?
这是我的代码:
Name=raw_input("Global name:")
def display():
print "Globally declared function has been called"
class base(object):
def __init__(self):
self.bname='base class'
print self.bname
def bfun1(self):
display()
class derived(base):
def __init__(self):
self.dname="derived class"
print self.dname
def bshow(self):
self.bsname=raw_input(super(derived,self).__init__())
print self.bsname
display()
ob=derived()
ob.__init__()
ob.bshow()
ob.bfun1()