On Jul 25, 3:05 pm, "Eduardo \"EdCrypt\" O. Padoan" <[EMAIL PROTECTED]> wrote: > def flatten(listOfLists): > return list(chain(*listOfLists)) > > >Fromhttp://www.python.org/doc/2.4/lib/itertools-recipes.html > > -- > EduardoOPadoan (eopadoan->altavix::com) > Bookmarks:http://del.icio.us/edcrypt
That doesn't necessarily work: import itertools x = (1, 2, [3, 4, (5, 6)]) y = ([1, 2, (3, 4)], 5, 6) z = (1, [2, 3, (4, 5)], 6) def flatten(listOfLists): return list(itertools.chain(*listOfLists)) print flatten(x) print flatten(y) print flatten(z) ==> TypeError: chain argument #1 must support iteration -- http://mail.python.org/mailman/listinfo/python-list