Generator chaining?

John Doe no at spam.com
Tue Aug 29 15:41:37 EDT 2006


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



More information about the Python-list mailing list