On Sat, May 8, 2010 at 3:41 PM, Oltmans <rolf.oltm...@gmail.com> wrote: > Hi, I've a list that looks like following > > a = [ [1,2,3,4], [5,6,7,8] ] > > Currently, I'm iterating through it like > > for i in [k for k in a]: > for a in i: > print a > > but I was wondering if there is a shorter, more elegant way to do it?
How about itertools? In python 2.6: >>> a = [ [1,2,3,4], [5,6,7,8] ] >>> from itertools import chain >>> for i in chain(*a): ... print i ... 1 2 3 4 5 6 7 8 -- http://mail.python.org/mailman/listinfo/python-list