TypeError:'bool'对象不可调用

Mik*_*ike 17 python

我是python的新手.我收到了一个错误

while not cls.isFilled(row,col,myMap):
TypeError: 'bool' object is not callable
Run Code Online (Sandbox Code Playgroud)

你能指导一下如何解决这个问题吗?第一个"if"检查没问题,但"while not"有这个错误.

def main(cls, args):
        ...
        if cls.isFilled(row,col,myMap):
            numCycles = 0

        while not cls.isFilled(row,col,myMap):
            numCycles += 1


def isFilled(cls,row,col,myMap):
        cls.isFilled = True
        ## for-while
        i = 0
        while i < row:
            ## for-while
            j = 0
            while j < col:
                if not myMap[i][j].getIsActive():
                    cls.isFilled = False
                j += 1
            i += 1
        return cls.isFilled
Run Code Online (Sandbox Code Playgroud)

Bre*_*arn 48

你呢cls.isFilled = True.这会覆盖调用的方法isFilled,并将值替换为True.这种方法现在已经消失,你不能再打电话了.因此,当您再次尝试再次调用时,会出现错误,因为它不再存在.

解决方案使用的变量名称与方法名称不同.