What happened to __cmp__() in Python 3.x?

Xavier Ho contact at xavierho.com
Sun Aug 16 05:45:42 EDT 2009


On Sun, Aug 16, 2009 at 7:38 PM, Mark Lawrence <breamoreboy at yahoo.co.uk>wrote:

>
> Blast, I posted the wrong flaming link, sorry everybody.
>

No, don't be sorry. I found your link very informative, and while it's a
little mixed, it could be useful.

I'm really looking for a way to set up Python classes' natural ordering for
sorting purposes. For example, every object of a class could own an
attribute called 'Value'. If I could get Python to sort() a list of classes
with that value, would the key=value parameter work, and is there a better
way than to redefine 3 or more of the rich comparison special methods, etc.

Also, I noticed heapq (the priority queue/heap queue module) doesn't use the
natural sorting order like sorted() does. Just saying. Could someone give it
a try?

Regards,

Ching-Yun "Xavier" Ho, Technical Artist

Contact Information
Mobile: (+61) 04 3335 4748
Skype ID: SpaXe85
Email: contact at xavierho.com
Website: http://xavierho.com/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20090816/a912d012/attachment-0001.html>


More information about the Python-list mailing list