This mirrors mathematical notation for things like ranges or equality checks
5 < x <= 25
x == y == 10
5 < x <= 25
x == y == 10
When looking at `a == b == c` we naturally assume that not only `a == b` and `b == c` but also `a == c` because equality is assumed to be transitive.
The problem is that in Python we can make `==` operator to do literally whatever we want, so in Python `==` doesn't have to be transitive.
You may argue that no reasonable person would define equality in such way that is not transitive.
To which I would reply that approximate comparison of floating point numbers looks perfectly reasonable to me.
EPSILON = 10**-9
class Foo:
def __eq__(self, other):
return other.bar - EPSILON <= self.bar <= other.bar + EPSILON