tee_lookahead¶

iteration_utilities.
tee_lookahead
(tee, i)¶ Inspect the ith upcoming value from a
tee()
object while leaving thetee()
object at its current position. Parameters
 tee
itertools.tee()
The tee object in which to look ahead.
 i
int
The index counting from the current position which should be peeked.
 tee
 Returns
 peekany type
The element at the ith upcoming index in the tee object.
 Raises
 IndexError
If the underlying iterator doesn’t have enough values.
Examples
>>> from iteration_utilities import tee_lookahead >>> from itertools import tee >>> t1, t2 = tee([1,2,3,4,5,6]) >>> tee_lookahead(t1, 0) 1 >>> tee_lookahead(t1, 1) 2 >>> tee_lookahead(t1, 0) 1