Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- >>> list(itertools.tee('ABC'))
- [<itertools._tee object at 0x109cebe88>, <itertools._tee object at 0x109cf3048>]
- >>> g1, g2 = itertools.tee('ABC')
- >>> g1
- <itertools._tee object at 0x109cf3108>
- >>> next(g1)
- 'A'
- >>> next(g2)
- 'A'
- >>> next(g2)
- 'B'
- >>> next(g2)
- 'C'
- >>> next(g2)
- Traceback (most recent call last):
- File "<stdin>", line 1, in <module>
- StopIteration
- >>> list(g1)
- ['B', 'C']
- >>> list(g2)
- []
- >>> list(zip(*itertools.tee('ABC')))
- [('A', 'A'), ('B', 'B'), ('C', 'C')]
- >>>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement