How to join two generators (or other iterables) in Python?
itertools.chain() should do it. It takes multiple iterables and yields from each one by one, roughly equivalent to: def chain(*iterables): for it in iterables: for element in it: yield element Usage example: from itertools import chain g = (c for c in ‘ABC’) # Dummy generator, just for example c = chain(g, ‘DEF’) # Chain … Read more