Constraints on __sub__, __eq__, etc.

Andrey Fedorov anfedorov at gmail.com
Thu Feb 18 11:19:02 EST 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: <http://mail.python.org/pipermail/python-list/attachments/20100218/98c909bd/attachment.html>


More information about the Python-list mailing list