Python how to iterate two infinite generators at the same time? -


i'd iterate on number of infinite generators:

def x(y):     while true:         in xrange(y):             yield  i,j in zip(x(5),x(3)):     print i,j 

the code above will produce nothing. doing wrong?

that's because python 2 zip tries create list getting elements generator ever produce. want iterator, i.e. itertools.izip.

in python 3 zip works izip.


Comments

Popular posts from this blog

javascript - Clear button on addentry page doesn't work -

c# - Selenium Authentication Popup preventing driver close or quit -

tensorflow when input_data MNIST_data , zlib.error: Error -3 while decompressing: invalid block type -