"Bryan" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > George Sakkis wrote: <snip> > > "The returned group is itself an iterator that shares the underlying > > iterable with groupby(). Because the source is shared, when the groupby > > object is advanced, the previous group is no longer visible. So, if > > that data is needed later, it should be stored as a list" > > > > George > > > > i read that description in the docs so many times before i posted here. now that > i read it about 10 more times, i finally get it. there's just something about > the wording that kept tripping me up, but i can't explain why :) > > thanks, > > bryan >
So here's how to save the values from the iterators while iterating over the groupby: >>> m = [(x,list(y)) for x,y in groupby([1, 1, 1, 2, 2, 3])] >>> m [(1, [1, 1, 1]), (2, [2, 2]), (3, [3])] -- Paul -- http://mail.python.org/mailman/listinfo/python-list