On Mon, 14 Mar 2011 23:37:06 +0000, Nobody wrote:

> 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.

You mean like this?

http://docs.python.org/dev/library/functools.html#functools.cmp_to_key




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

Reply via email to