Heres a couple of methods adding one point to another and creating a new point from adding points.
class Point(object): def __init__(self, x, y): self.x = x self.y = y def __repr__(self): return 'Point> x: {}, y: {}'.format(self.x, self.y) def add_points_to_return_a_new_point(self, point): return Point(self.x + point.x, self.y + point.y) def __add__(self, point): self.x += point.x self.y += point.y #main objectA = Point(3,5) objectB = Point(7,5) print(objectA) objectA + objectB print(objectA) objectC = objectA.add_points_to_return_a_new_point(objectB) print(objectC)
Output:Point> x: 3, y: 5
Point> x: 10, y: 10
Point> x: 17, y: 15