
Nov. 29, 2003
10:32 p.m.
On Sat, Nov 29, 2003 at 01:12:34AM -0500, Raymond Hettinger wrote:
[Guido]
I would make one change: after looking at another use case, I'd like to change the outer iterator to produce (key, grouper) tuples. This way, you can write things like
totals = {} for key, group in groupby(sequence): totals[key] = sum(group)
Heh. I love that!
Here is an implementation that translates readily into C. It uses Guido's syntax and meets my requirement that bad things don't happen when someone runs the outer iterator independently of the inner iterator.
I updated my implementation according to your guideline. Please see attachments. Docstrings are still insufficient due to my english shortage. :) Thanks! Regards, Hye-Shik