
Feb. 25, 2013
12:56 p.m.
On 2013-02-25, at 13:37 , Joao S. O. Bueno wrote:
Hi all!
What is the problem with iterttols.tee even? It is almots the samething - although much more flexible, than what is proposed on this thread.
from itertools import tee my_iter, peek = tee(iter(range(3)), 2) next(peek) 0 next(my_iter) 0
Verbose way to do the same thing: you have to tee() + next() once per "peek()". And splitting to subroutines means these subroutines will have to return an iterator alongside any potential value as they'll have to tee() themselves.