George Sakkis wrote:
I stumbled upon the following strangeness (python 2.6.2):
<method-wrapper '__gt__' of type object at 0x822b7c0>
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.
"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
From http Fri Oct 2 22:49:34 2009
From: http (Paul Rubin)
Date: 02 Oct 2009 13:49:34 -0700
Subject: Q: sort's key and cmp parameters
Scott David Daniels <Scott.Daniels at Acm.Org> writes:
Most cases are moreeasily done with key, and it is
a good idea to make the most accessible way to a sort be the most
efficient one. In the rare case that you really want each comparison,
the cmp-injection function will do nicely (and can be written as a
I don't think wrapping the sorted objects in an otherwise useless
special purpose class is "nicely", either from a performance or from a
code verbosity point of view. I avoid Java and its useless extra
classes for a reason ;-).
In short, make the easy path the fast path, and more will use it;
provide two ways, and the first that springs to mind is the one
I think we are saying the same thing. Python 2.x provides two ways
and you can use whichever one fits the application better. I have
never understood why Python 3.x finds it necessary to break one of
them. Maybe I can migrate to Haskell by the time Python 2.x becomes