[Python-Dev] decorate-sort-undecorate

Guido van Rossum guido at python.org
Mon Oct 13 16:35:59 EDT 2003


> From: Raymond Hettinger [mailto:raymond.hettinger at verizon.net]
> 
> > For Py2.4, I propose adding an optional list.sort() argument to
> > support the decorate-sort-undecorate pattern.
> [...]
>  
> > def sort(self, cmpfunc=None, decorator=None):

[Paul Moore]
> I like it! But "decorator" isn't a good name - it describes how it's
> being done, rather than what is being done. How about "key"? After
> all, "key=str.lower" reads more or less as "the key is the lowercase
> equivalent of the value", and "key=ages.__getitem__" reads "get the
> key by getting the appropriate item from the ages dictionary".

Agreed, that was my first thought too.

> But names apart, it's nice. It lets people use the builtin, without
> going for the performance-reducing comparison function...

+1

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



More information about the Python-Dev mailing list