Re: Constraints on __sub__, __eq__, etc.

2010-02-19 Thread Roald de Vries
On Feb 18, 2010, at 5:28 PM, Stephen Hansen wrote: On Thu, Feb 18, 2010 at 8:19 AM, Andrey Fedorov anfedo...@gmail.comwrote: 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

Re: Constraints on __sub__, __eq__, etc.

2010-02-19 Thread Chris Rebert
On Fri, Feb 19, 2010 at 2:30 AM, Roald de Vries r...@roalddevries.nl wrote: On Feb 18, 2010, at 5:28 PM, Stephen Hansen wrote: On Thu, Feb 18, 2010 at 8:19 AM, Andrey Fedorov anfedo...@gmail.comwrote: It seems intuitive to me that the magic methods for overriding the +, -, , ==, , etc.

Re: Constraints on __sub__, __eq__, etc.

2010-02-19 Thread Peter Otten
Roald de Vries wrote: On Feb 18, 2010, at 5:28 PM, Stephen Hansen wrote: On Thu, Feb 18, 2010 at 8:19 AM, Andrey Fedorov anfedo...@gmail.comwrote: It seems intuitive to me that the magic methods for overriding the +, -, , ==, , etc. operators should have no sideffects on their operands.

Constraints on __sub__, __eq__, etc.

2010-02-18 Thread Andrey Fedorov
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

Re: Constraints on __sub__, __eq__, etc.

2010-02-18 Thread Stephen Hansen
On Thu, Feb 18, 2010 at 8:19 AM, Andrey Fedorov anfedo...@gmail.com 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

Re: Constraints on __sub__, __eq__, etc.

2010-02-18 Thread Andrey Fedorov
It may be intuitive to you, but its not true, written down anywhere, nor assumed by the language, and the mathematical meaning of the operators doesn't matter to Python. Python purposefully does not enforce anything for these methods. Right, so neither is anything in PEP-8, but it's still

Re: Constraints on __sub__, __eq__, etc.

2010-02-18 Thread Benjamin Kaplan
On Thu, Feb 18, 2010 at 11:19 AM, Andrey Fedorov anfedo...@gmail.com 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

Re: Constraints on __sub__, __eq__, etc.

2010-02-18 Thread Robert Kern
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.

Re: Constraints on __sub__, __eq__, etc.

2010-02-18 Thread Jean-Michel Pichavant
Andrey Fedorov wrote: It may be intuitive to you, but its not true, written down anywhere, nor assumed by the language, and the mathematical meaning of the operators doesn't matter to Python. Python purposefully does not enforce anything for these methods. Right, so neither is