Constraints on __sub__, __eq__, etc.

Andrey Fedorov anfedorov at
Thu Feb 18 17:19:02 CET 2010

It seems intuitive to me that the magic methods for overriding the +, -, <,
==, >, etc. operators should have no sideffects on their operands. Also,
that == should be commutative and transitive, that > and < should be
transitive, and anti-commutative.

Is this intuition written up in a PEP, or assumed to follow from the
mathematical meanings?

- Andrey
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the Python-list mailing list