Ordering python sets
greg
greg at cosc.canterbury.ac.nz
Mon Oct 27 22:28:53 EDT 2008
On approximately 10/27/2008 10:27 AM, came the following characters from
the keyboard of Peter Otten:
> Here's a class that can negate arbitrary values
>
> ... def __init__(self, value):
> ... self.value = value
> ... def __cmp__(self, other):
> ... return -cmp(self.value, other.value)
Unfortunately, the __cmp__ method has been eliminated from
3.0 as well, so this won't work as-is. You would need to
override __lt__, __eq__, etc.
--
Greg
More information about the Python-list
mailing list