0

新しいオブジェクトを作成しようとしていますが、トレースバックに次のエラーが表示されます:

    p1 = point(point.x+jumpValue, point.y)
TypeError: 'point' object is not callable

同じファイルでクラスを定義しました。

class point(object):
    def __init__(self, x, y):
        self.x = x
        self.y = y
4

1 に答える 1

5

クラスではない同じ名前の変数があります。Point代わりに使用するクラスの名前を変更します。

class Point(object):
    def __init__(self, x, y):
        self.x = x
        self.y = y

次に、次のように呼び出します。

p1 = Point(point.x + jumpValue, point.y)
于 2013-02-22T21:24:51.490 に答える