Ulrich Eckhardt wrote: > I have a list [1,2,3,4,5,6] which I'd like to iterate as (1,2), (3,4), > (5,6). I can of course roll my own, but I was wondering if there was > already some existing library function that already does this. > > > def as_pairs(seq): > i = iter(seq) > yield (i.next(), i.next())
Obviously this code does _not_ do what I want, it must be like this: def as_pairs(seq): i = iter(seq) while True: yield (i.next(), i.next()) Gah! Uli -- Sator Laser GmbH Geschäftsführer: Thorsten Föcking, Amtsgericht Hamburg HR B62 932 -- http://mail.python.org/mailman/listinfo/python-list