运算符重载

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

    def __eq__(self, other):
        return \
            self.x == other.x and \
            self.y == other.y

    def __ne__(self, other):
        return \
            self.x != other.x or \
            self.y != other.y


p1 = Point(11)
p2 = Point(22)
p3 = Point(11)

equal1 = p1 == p2
# equal1 is False
equal2 = p1 == p3
# equal2 is True
equal3 = p1 != p3
# equal3 is False

print(equal1)
print(equal2)
print(equal3)