Generator chaining?
Jean-Paul Calderone
exarkun at divmod.com
Tue Aug 29 16:04:14 EDT 2006
On Tue, 29 Aug 2006 22:41:37 +0300, John Doe <no at spam.com> wrote:
>This is sort of a feature request/idea: Chaining generators.
>
>If you have two lists (or tuples) and you add them, the result is a
>concatenation of the two.
>I think it would be nice if it was possible to do something similar with
>generators. The best way to explain is by code example:
>
>def add_generators(gen1, gen2):
> for x in gen1:
> yield x
> for y in gen2:
> yield y
>
>Just a thought...
You can chain any iterators using itertools.chain().
Jean-Paul
More information about the Python-list
mailing list