generate tuples from sequence
tim at tdw.net
Wed Jan 17 15:05:39 CET 2007
On 17 Jan 2007 04:50:33 -0800, Will McGugan <will at willmcgugan.com> wrote:
> Will McGugan wrote:
> > Hi,
> > 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
> Forgot to add, for my purposes I will always have a sequence with a
> multiple of n items.
something along the lines of.......
>>> [ (x,x+1,x+2) for x in xrange(0,9,3) ]
[(0, 1, 2), (3, 4, 5), (6, 7, 8)]
More information about the Python-list