Will McGugan wrote:

> I'd like a generator that takes a sequence and yields tuples containing
> n items of the sqeuence, but ignoring the 'odd' items. For example
> 
> take_group(range(9), 3) -> (0,1,2) (3,4,5) (6,7,8)

I like

>>> items = range(9)
>>> N = 3
>>> zip(*[iter(items)]*N)
[(0, 1, 2), (3, 4, 5), (6, 7, 8)]

Peter
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to