On Mar 16, 9:24 am, Matt Nordhoff <[EMAIL PROTECTED]> wrote: > mpc wrote: > > def concatenate(sequences): > > for seq in sequences: > > for item in seq: > > yield item > > You should check out itertools.chain(). It does this. You call it like > "chain(seq1, seq2, ...)" instead of "chain(sequences)" though, which may > be a problem for you.
Solved rather easily by chain(*sequences): >>> from itertools import chain >>> def concat(sequences): ... return chain(*sequences) ... >>> concat([[1,2], [3, 4], [5], [6, 7, 8]]) <itertools.chain object at 0xb7cffc0c> >>> list(concat([[1,2], [3, 4], [5], [6, 7, 8]])) [1, 2, 3, 4, 5, 6, 7, 8] wondering if google groups will add a .sig or not-ly, Marius Gedminas -- http://mail.python.org/mailman/listinfo/python-list