How is __eq__ handled in Python and in what order?
The a == b expression invokes A.__eq__, since it exists. Its code includes self.value == other. Since int’s don’t know how to compare themselves to B’s, Python tries invoking B.__eq__ to see if it knows how to compare itself to an int. If you amend your code to show what values are being compared: it will print: