Python Generators

Matt Nordhoff mnordhoff at
Sun Mar 16 08:24:39 CET 2008

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.

The rest of itertools might be interesting too:



More information about the Python-list mailing list