On Sat, Jan 3, 2009 at 9:34 AM, Sander Sweers <[email protected]> wrote: > On Sat, Jan 3, 2009 at 05:15, Kent Johnson <[email protected]> wrote: >> On Fri, Jan 2, 2009 at 6:12 PM, Sander Sweers <[email protected]> >> wrote: >>> not understand how operator.itemgetter(1) works. >> >> See >> http://personalpages.tds.net/~kent37/kk/00007.html#e7the-operator-module > > Ok, if I understand this correctly counts.iteritems() creates a tuple > (name, count) and this is passed to operator.itemgetter() which take > the second value to sort the list.
Almost right. The (name, count) tuple is passed to the function returned by operator.itemgetter(). > > Previously I used a function with cmp to sort datetime.date objects > but this works way better :-) Yes, the key= parameter to sort() pretty much obsoletes the use of a comparison function. Kent _______________________________________________ Tutor maillist - [email protected] http://mail.python.org/mailman/listinfo/tutor
