I have two iterators, a list and an itertools.count object (i.e. an infinite value generator). I would like to merge these two into a resulting ite
list
itertools.count
You can do something that is almost exaclty what @Pramod first suggested.
def izipmerge(a, b): for i, j in itertools.izip(a,b): yield i yield j
The advantage of this approach is that you won't run out of memory if both a and b are infinite.