Guido rethinking removal of cmp from sort method

Nobody nobody at nowhere.com
Mon Mar 14 19:37:06 EDT 2011


On Mon, 14 Mar 2011 12:39:35 -0700, Paul Rubin wrote:

> Finally I concocted an "infinite" example which we agreed is artificial:
> you are given a list of generators denoting real numbers, for example
> pi generates the infinite sequence 3,1,4,1,5,9... while e generates 
> 2,7,1,8,...  You can sort these with cmp but not with key.

Is there some restriction on the return type of the key= function? If not,
you can define a class with appropriate comparison methods and have key=
return instances of that class.




More information about the Python-list mailing list