私は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()