私はスーパーファンクションで自分の手を試していましたが、以下は実行していたコードです。スーパーファンクションはPythonのメソッドの中で呼び出されました2
class scene(object):
def enter(self):
print "a vllan s n your way. what you'll do?"
class centralcorrdor(scene):
print "startng pont of the game."
super(centralcorrdor,self).enter()
a = centralcorrdor()
ただし、これはエラーです。
class centralcorrdor(scene):
File "game.py", line 8, in centralcorrdor
super(centralcorrdor,self).enter()
NameError: name 'centralcorrdor' is not defined
これはありません。
class scene(object):
def enter(self):
print "a vllan s n your way. what you'll do?"
class centralcorrdor(scene):
#print "startng pont of the game."
def func(self):
super(centralcorrdor,self).enter()
#scene.enter()
a = centralcorrdor()
a.func()
誰かがなぜそれを伝えることができますか?それはスーパークラスが子クラスのメソッドの中から呼び出されるのでしょうか?
コードブロックを選択し、中括弧でボタンをクリックすると、投稿のコード行を整形できます。 – glibdud
クラスの仕組みについては混乱しているようです。なぜあなたはsuper- と呼ぶのですか、あるいは方法の外側に印刷しますか? –
また、キーボードの 'i'キーが壊れていますか?そのコードには7つの「i」があります。 –