参考官方文档https://docs.python.org/zh-cn/3/reference/datamodel.html?highlight=eq#object.eq
-
x==y调用x.__eq__(y)
-
默认情况下,object 通过使用 is 来实现__eq__(),并在比较结果为假值时返回NotImplemented
class A(object): def __init__(self, age): self.age = age def __eq__(self, other): return super().__eq__(other)