why should dict not be callable?

Fredrik Lundh fredrik at pythonware.com
Tue Oct 17 15:37:51 EDT 2006


georgeryoung 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)

</F>




More information about the Python-list mailing list