SHARE
TWEET

Untitled

a guest Sep 19th, 2019 82 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. >>> list(itertools.tee('ABC'))
  2. [<itertools._tee object at 0x109cebe88>, <itertools._tee object at 0x109cf3048>]
  3. >>> g1, g2 = itertools.tee('ABC')
  4. >>> g1
  5. <itertools._tee object at 0x109cf3108>
  6. >>> next(g1)
  7. 'A'
  8. >>> next(g2)
  9. 'A'
  10. >>> next(g2)
  11. 'B'
  12. >>> next(g2)
  13. 'C'
  14. >>> next(g2)
  15. Traceback (most recent call last):
  16.   File "<stdin>", line 1, in <module>
  17. StopIteration
  18. >>> list(g1)
  19. ['B', 'C']
  20. >>> list(g2)
  21. []
  22. >>> list(zip(*itertools.tee('ABC')))
  23. [('A', 'A'), ('B', 'B'), ('C', 'C')]
  24. >>>
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top