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 回答