How do I merge two python iterators?

前端 未结 13 1218
花落未央
花落未央 2020-12-06 09:29

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

13条回答
  •  执念已碎
    2020-12-06 10:08

    I prefer this other way which is much more concise:

    iter = reduce(lambda x,y: itertools.chain(x,y), iters)
    

提交回复
热议问题