On May 27, 7:50 pm, Raymond Hettinger <[EMAIL PROTECTED]> wrote: > The groupby itertool came-out in Py2.4 and has had remarkable > success (people seem to get what it does and like using it, and > there have been no bug reports or reports of usability problems).
With due respect, I disagree. Bug ID #1212077 is either a bug report or a report of a usability problem, depending on your point of view. You may disagree on whether or not this is a problem that needs to be be fixed, but it *is* a report. http://sourceforge.net/tracker/index.php?func=detail&aid=1212077&group_id=5470&atid=105470 I think the semantics of the itertools groupby are too tricky for naive users--I find them confusing myself, and I've been using Python for quite a while. I still hope that Python will someday gain a groupby function suitable for ordinary use. Until that happens, I recommend the following cookbook entry: # from http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/259173 class groupby(dict): def __init__(self, seq, key=lambda x:x): for value in seq: k = key(value) self.setdefault(k, []).append(value) __iter__ = dict.iteritems Mike -- http://mail.python.org/mailman/listinfo/python-list