运算符重载

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

    def __add__(self, other):
        x = self.x + other.x
        y = self.y + other.y
        return Point(x, y)


p1 = Point(11)
p2 = Point(22)
p3 = p1 + p2
# p3.x is 3 and p3.y is 3
p3 += Point(35)
# p3.x is 6 and p3.y is 8

print(p3.x, p3.y)