why should dict not be callable?

georgeryoung at gmail.com georgeryoung at gmail.com
Tue Oct 17 20:44:56 EDT 2006


On Oct 17, 3:37 pm, Fredrik Lundh <fred... at pythonware.com> wrote:
> georgeryo... at gmail.com wrote:
> > A couple of times recently I've come across this problem:  I have a
> > large list to sort and I need to the the "key=function" argument to
> > sort appropriately.  But I actually have the key mapping in a big
> > dictionary.so use a bound method:
>
>      L.sort(key=key_dict.get)

Duh!  Why didn't I think of that... Thanks guys, that's perfect.

-- George




More information about the Python-list mailing list