int rich comparisons

Robert Kern robert.kern at gmail.com
Fri Oct 2 22:47:04 CEST 2009


George Sakkis wrote:
> I stumbled upon the following strangeness (python 2.6.2):
> 
>>>> getattr(int, '__gt__')
> <method-wrapper '__gt__' of type object at 0x822b7c0>
> 
>>>> getattr(5, '__gt__')
> Traceback (most recent call last):n
>   File "<stdin>", line 1, in <module>
> AttributeError: 'int' object has no attribute '__gt__'
> 
> Is this a bug ?

I believe that ints in the 2.x series still use __cmp__. In Python 3.x, __gt__ 
and the rest are defined.

-- 
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




More information about the Python-list mailing list