Python tee Iterator


Python tee(iter[,n=2]) iterator repeats iterator iter n times, if n is not specified, n=2.

>>> from itertools import *
>>> x = starmap(max,[[5,14,5],[2,34,6],[3,5,2]])
>>> y = tee(x) #default repeat 2 times
>>> for i in y:
>>> 	for j in i:
>>> 		print (j)
14
34
5
14
34
5

>>> from itertools import *
>>> x = starmap(max,[[5,14,5],[2,34,6],[3,5,2]])
>>> y = tee(x,3) #repeat 3 times
>>> for i in y:
>>> 	for j in i:
>>> 		print (j)
14
34
5
14
34
5
14
34
5