Re: Python interpreter bug
alainpoint@yaho o.fr wrote:[color=blue]
> In fact, i want to sort the list based on the 'allocated attribute' and
> at the same time, test membership based on the id attribute.
> __cmp__ logically implies an ordering test, not an identity test. These
> two notions seems to be confounded in python which is unfortunate. Two
> objects could have the same rank while still being different.[/color]
In that case, define __lt__ and __eq__ separately instead of __cmp__.
list.sort() will use __lt__ if it's provided rather than __cmp__.
--
Robert Kern
rkern@ucsd.edu
"In the fields of hell where the grass grows high
Are the graves of dreams allowed to die."
-- Richard Harter
alainpoint@yaho o.fr wrote:[color=blue]
> In fact, i want to sort the list based on the 'allocated attribute' and
> at the same time, test membership based on the id attribute.
> __cmp__ logically implies an ordering test, not an identity test. These
> two notions seems to be confounded in python which is unfortunate. Two
> objects could have the same rank while still being different.[/color]
In that case, define __lt__ and __eq__ separately instead of __cmp__.
list.sort() will use __lt__ if it's provided rather than __cmp__.
--
Robert Kern
rkern@ucsd.edu
"In the fields of hell where the grass grows high
Are the graves of dreams allowed to die."
-- Richard Harter
Comment