[Tutor] Kent's top poster script operator.itemgetter()

Sander Sweers sander.sweers at gmail.com
Sat Jan 3 15:34:26 CET 2009


On Sat, Jan 3, 2009 at 05:15, Kent Johnson <kent37 at tds.net> wrote:
> On Fri, Jan 2, 2009 at 6:12 PM, Sander Sweers <sander.sweers at gmail.com> 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.

Previously I used a function with cmp to sort datetime.date objects
but this works way better :-)

Thanks
Sander


More information about the Tutor mailing list