kj <[EMAIL PROTECTED]> wrote:
> Is there a special pythonic idiom for iterating over a list (or
> tuple) two elements at a time?

I don't know of one, and I shouldn't be answering, but the following
should work:

def gulp_two(items):
  for i,j in zip(items[0::2], items[1::2]):
    yield (i,j)

Let's see...
>>> list(gulp_two(range(10)))
[(0, 1), (2, 3), (4, 5), (6, 7), (8, 9)]

Okay, it works.

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

Reply via email to