A class that defines attributes that are not present in its superclasses may need to override the __eq__() method (__ne__() should also be defined).

Adding additional attributes without overriding __eq__() means that the additional attributes will not be accounted for in equality tests.

Override the __eq__ method.

In the following example the ColorPoint class subclasses the Point class and adds a new attribute, but does not override the __eq__ method.

  • Peter Grogono, Philip Santas: Equality in Object Oriented Languages