On 2007-02-02, Laurent Pointal <[EMAIL PROTECTED]> wrote: > Neil Cerutti a écrit : >> On 2007-02-02, ardief <[EMAIL PROTECTED]> wrote: ><zip> > >> This is a job for... duhn-duhn-DAAAAH! Captain CHAOS! >> >> Er... I mean itertools.groupby. >> ><zip> >> def key_func(t): >> return t[0] > > Not needed: --> from operator import itemgetter
I agree. But I used it anyway, to make it easier to see that the sort and the groupby must be and are using the same key function. In this case I admit it's a not a huge readability win, but I was also following the "Do Not Repeat Yourself Rule", which makes the key function easier to refactor. > See in the example: > http://docs.python.org/lib/itertools-example.html > > So much stuff in libraries, so few we know. Thanks to doc > writers, Usenet contributors & Google search engines. Yup. -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list