Python 3.0, rich comparisons and sorting order

Carlos Ribeiro carribeiro at gmail.com
Tue Sep 21 14:35:47 EDT 2004


----- Original Message -----
From: Batista, Facundo <fbatista at unifon.com.ar>
> You could also do that passing a function to sort(). 
 
I know it, and that's exactly my question -- if this is going to be
the way to do it in Python 3000. Today (2.4) there are FOUR ways to
make it work: passing a compare function as an argument to sort(),
passing a key funciton as an argument to sort(), implementing a
__cmp__ function, or implementing the rich comparison methods. If the
main goal of Py3K  is to have only one obvious way to do it, what one
is it going to be? I think that the best way should be the simplest
one: make sort() work whatever is passed to it in a reasonably way,
and decide to have one preferred way to extend its behavior.

> Define "reasonable result" with different datatypes. 

Now that's a harder question :-) Any ordering for multiple types is
going to be arbitrary -- but it still may be considered reasonable if
it reflects our common sense when it comes to ordering. In some cases,
it's still a matter of choice, but once decided, it's deterministic,
and that's what it takes for sorting.

--
http://mail.python.org/mailman/listinfo/python-list





-- 
Carlos Ribeiro
Consultoria em Projetos
blog: http://rascunhosrotos.blogspot.com
blog: http://pythonnotes.blogspot.com
mail: carribeiro at gmail.com
mail: carribeiro at yahoo.com



More information about the Python-list mailing list