josh logan <[EMAIL PROTECTED]> writes:
> It looks like __cmp__ is still in the documentation, and it seems to
> work somewhat in Python 3.0rc1. Here is the link to the documnetation
> http://docs.python.org/dev/3.0/reference/datamodel.html#object.__cmp__
Thanks, I've now filed a bug report for th
josh logan wrote:
Here is a minimal example showing the problematic behavior.
class Int():
def __init__(self, i):
self.i = i
def __cmp__(self, other):
return cmp(self.i, other.i)
Is = [Int(i) for i in range(8)]
Is.sort() # throws TypeError: unorderable types Int() < Int
On Sep 22, 9:29 am, Hrvoje Niksic <[EMAIL PROTECTED]> wrote:
> josh logan <[EMAIL PROTECTED]> writes:
> > sorted(P) # throws TypeError: unorderable types Player() < Player()
>
> > The sorted function works when I define __lt__.
> > I must be misreading the documentation, because I read for the
> >
josh logan <[EMAIL PROTECTED]> writes:
> sorted(P) # throws TypeError: unorderable types Player() < Player()
>
> The sorted function works when I define __lt__.
> I must be misreading the documentation, because I read for the
> documentation __cmp__ that it is called if none of the other rich
> co
On Sep 22, 7:32 am, Sion Arrowsmith <[EMAIL PROTECTED]>
wrote:
> josh logan <[EMAIL PROTECTED]> wrote:
>
> >sorted(P) # throws TypeError: unorderable types Player() < Player()
>
> >The sorted function works when I define __lt__.
> >I must be misreading the documentation, because I read for the
> >
On 22 Sep, 11:52, josh logan <[EMAIL PROTECTED]> wrote:
> On Sep 22, 3:41 am, Arnaud Delobelle <[EMAIL PROTECTED]> wrote:
>
>
>
> > On 22 Sep, 04:05, josh logan <[EMAIL PROTECTED]> wrote:
>
> > > Hello,
>
> > > I have 2 questions. Say I have this class:
>
> > > class Player(object):
> > > def _
josh logan <[EMAIL PROTECTED]> wrote:
>sorted(P) # throws TypeError: unorderable types Player() < Player()
>
>The sorted function works when I define __lt__.
>I must be misreading the documentation, because I read for the
>documentation __cmp__ that it is called if none of the other rich
>comparis
josh logan wrote:
> A better example would be sorting by increasing last name and
> decreasing first name. This would be easy with the sort function
> comparator, but I can't see how to do the same with the key argument.
> Is the only solution to decorate the Player objects in another class
> that
On Sep 22, 3:41 am, Arnaud Delobelle <[EMAIL PROTECTED]> wrote:
> On 22 Sep, 04:05, josh logan <[EMAIL PROTECTED]> wrote:
>
>
>
> > Hello,
>
> > I have 2 questions. Say I have this class:
>
> > class Player(object):
> > def __init__(self, fname, lname, score):
> > self.score = score
> >
On 22 Sep, 04:05, josh logan <[EMAIL PROTECTED]> wrote:
> Hello,
>
> I have 2 questions. Say I have this class:
>
> class Player(object):
> def __init__(self, fname, lname, score):
> self.score = score
> self.fname = fname
> self.lname = lname
> def __cmp__(self, oth
Hello,
I have 2 questions. Say I have this class:
class Player(object):
def __init__(self, fname, lname, score):
self.score = score
self.fname = fname
self.lname = lname
def __cmp__(self, other):
return (-cmp(self.score, other.score) or
cmp
11 matches
Mail list logo