[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.python

Re: Constraints on __sub__, __eq__, etc.

Robert Kern

2/18/2010 4:40:00 PM

On 2010-02-18 10:19 AM, Andrey Fedorov wrote:
> 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?

Some of it is covered in the reference manual. E.g.

http://docs.python.org/reference/datamodel.html#obj...

--
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless enigma
that is made terrible by our own mad attempt to interpret it as though it had
an underlying truth."
-- Umberto Eco