Re: [Python-Dev] NotImplemented comparisons

2007-08-03 Thread Facundo Batista
2007/8/2, Facundo Batista <[EMAIL PROTECTED]>: > > Given that you 'should' return an int, doing elsewise has undefined > > results. > > I'll fix decimal to always return sane values from __cmp__, :) Done, thanks again everybody! -- .Facundo Blog: http://www.taniquetil.com.ar/plog/ PyAr: ht

Re: [Python-Dev] NotImplemented comparisons

2007-08-02 Thread Guido van Rossum
On 8/2/07, Georg Brandl <[EMAIL PROTECTED]> wrote: > Returning anything other than an int or NotImplemented raises an exception. > NotImplemented seems to be special cased so that the other object's > __cmp__ can be tried too. Oops, sorry for the misinformation. :-( -- --Guido van Rossum (home p

Re: [Python-Dev] NotImplemented comparisons

2007-08-02 Thread Facundo Batista
2007/8/2, Terry Reedy <[EMAIL PROTECTED]>: > Given that you 'should' return an int, doing elsewise has undefined > results. I'll fix decimal to always return sane values from __cmp__, :) Thank you all! Regards, -- .Facundo Blog: http://www.taniquetil.com.ar/plog/ PyAr: http://www.python.

Re: [Python-Dev] NotImplemented comparisons

2007-08-02 Thread Georg Brandl
Terry Reedy schrieb: > "Facundo Batista" <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] > | >>> class C(object): > | ... def __cmp__(self, other): > | ... return NotImplemented > | ... > > Given that you 'should' return an int, doing elsewise has undefined > results.

Re: [Python-Dev] NotImplemented comparisons

2007-08-02 Thread Facundo Batista
2007/8/2, Paul Moore <[EMAIL PROTECTED]>: > A wild guess: c < None falls back to checking c.__cmp__(None) < 0. > This translates to NotImplemented < 0, and as the ordering of built in > types is implementation dependent, maybe that explains the difference > between Windows and Linux? "NotImplemen

Re: [Python-Dev] NotImplemented comparisons

2007-08-02 Thread Georg Brandl
Facundo Batista schrieb: > 2007/8/2, Guido van Rossum <[EMAIL PROTECTED]>: > >> NonImplemented isn't treated as special when returned by __cmp__(); >> __cmp__ is not considered a binary operator like __add__. (__lt__ and >> friends *do* get treated as such -- but instead of __rlt__ we use >> __gt_

Re: [Python-Dev] NotImplemented comparisons

2007-08-02 Thread Terry Reedy
"Facundo Batista" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] | >>> class C(object): | ... def __cmp__(self, other): | ... return NotImplemented | ... Given that you 'should' return an int, doing elsewise has undefined results. | >>> c = C() | >>> print c < None I

Re: [Python-Dev] NotImplemented comparisons

2007-08-02 Thread Georg Brandl
Guido van Rossum schrieb: > NonImplemented isn't treated as special when returned by __cmp__(); > __cmp__ is not considered a binary operator like __add__. (__lt__ and > friends *do* get treated as such -- but instead of __rlt__ we use > __gt__, etc.) But if it's not treated as special, why doesn'

Re: [Python-Dev] NotImplemented comparisons

2007-08-02 Thread Paul Moore
On 02/08/07, Facundo Batista <[EMAIL PROTECTED]> wrote: > I understand that is tricky how NotImplemented and comparisons interact. > > But how do you explain the difference in behaviour between Linux and Windows? A wild guess: c < None falls back to checking c.__cmp__(None) < 0. This translates to

Re: [Python-Dev] NotImplemented comparisons

2007-08-02 Thread Facundo Batista
2007/8/2, Guido van Rossum <[EMAIL PROTECTED]>: > NonImplemented isn't treated as special when returned by __cmp__(); > __cmp__ is not considered a binary operator like __add__. (__lt__ and > friends *do* get treated as such -- but instead of __rlt__ we use > __gt__, etc.) I understand that is tr

Re: [Python-Dev] NotImplemented comparisons

2007-08-02 Thread Guido van Rossum
NonImplemented isn't treated as special when returned by __cmp__(); __cmp__ is not considered a binary operator like __add__. (__lt__ and friends *do* get treated as such -- but instead of __rlt__ we use __gt__, etc.) --Guido On 8/2/07, Facundo Batista <[EMAIL PROTECTED]> wrote: > People: > > Pab

[Python-Dev] NotImplemented comparisons

2007-08-02 Thread Facundo Batista
People: Pablo Hoffman opened this bug: "[1764761] Decimal comparison with None fails in Windows". It's not a Decimal problem, see the differente behaviour of this basic test in Linux and Windows: Python 2.5.1 (r251:54863, May 2 2007, 16:56:35) [GCC 4.1.2 (Ubuntu 4.1.2-0ubuntu4)] on linux2 >>> c