[Python-Dev] decorate-sort-undecorate
Moore, Paul
Paul.Moore at atosorigin.com
Mon Oct 13 15:49:35 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):
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".
But names apart, it's nice. It lets people use the builtin, without
going for the performance-reducing comparison function...
Paul.
More information about the Python-Dev
mailing list