Python Generators

Matt Nordhoff mnordhoff at mattnordhoff.com
Sun Mar 16 03:24:39 EDT 2008


mpc wrote:

<snip>

> 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:

<http://docs.python.org/lib/module-itertools.html>

<snip>
-- 



More information about the Python-list mailing list