运算符重载

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

    def __xor__(self, power):
        self.x = self.x ** power
        self.y = self.y ** power
        return self


p1 = Point(23)
p1 = p1 ^ 3
# p1.x is 8 and p1.y is 27

p2 = Point(23)
p2 ^ 2
# p2.x is 4 and p2.y is 9

print(p1.x, p1.y)
print(p2.x, p2.y)