Python类__init__语法错误

时间:2015-03-05 08:21:10

标签: python initialization

from game_state import GameState
class TippyGameState(GameState):
    def __init__(self, p, interactive=False, current_total = 0):
        GameState.__init__(self, p)
        if interactive:
                self.size = int(input('Map size?')
                self.current_total = self.size * self.size
        self.size = 3
        self.over = (current_total < 1)

当我在终端中运行它时,它始终显示从self.current_total = self.size * self.size到结尾的语法错误,有人可以告诉我原因吗?

2 个答案:

答案 0 :(得分:2)

替换

self.size = int(input('Map size?')

self.size = int(input('Map size?'))

答案 1 :(得分:0)

在这种情况下,请尝试查看上一行。 将self.size = int(input('Map size?')替换为self.size = int(input('Map size?'))