Generator chaining?

Duncan Booth duncan.booth at invalid.invalid
Tue Aug 29 16:02:00 EDT 2006


John Doe 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...
> 

itertools.chain



More information about the Python-list mailing list