[Python-Dev] Re: Re: lists v. tuples

Guido van Rossum guido@python.org
Tue, 15 Apr 2003 19:49:50 -0400


> Guido> And then we should also change list.sort(), as Tim points
> Guido> out.  Maybe we can start introducing this earlier by using
> Guido> keyword arguments:
> 
> Guido>   list.sort(lt=function)     sorts using a < implementation
> Guido>   list.sort(cmp=function)    sorts using a __cmp__ implementation

[Andrew Koenig]
> The keyword argument might not be necessary: It is always possible
> for a function such as sort to figure out whether a comparison
> function is 2-way or 3-way (assuming it matters) by doing only one
> extra comparison.

That's cute, but a bit too magical for my taste...  It's not
immediately obvious how this would be done (I know how, but it would
require a lot of explaining).  Plus, -1 is a perfectly valid truth
value.

--Guido van Rossum (home page: http://www.python.org/~guido/)