You can use itertools.tee()
:
walk, walk2 = itertools.tee(walk)
Note that this might “need significant extra storage”, as the documentation points out.
More Related Contents:
- Understanding generators in Python
- Generator expressions vs. list comprehensions
- How to build a basic iterator?
- How do you programmatically set an attribute?
- Saving and loading multiple objects in pickle file?
- Accessing Object Memory Address
- Elegant way to check if a nested key exists in a dict?
- What’s the shortest way to count the number of items in a generator/iterator?
- how to split an iterable in constant-size chunks
- Is there a generator version of `string.split()` in Python?
- Python random sample with a generator / iterable / iterator
- How to look ahead one element (peek) in a Python generator?
- How to len(generator()) [duplicate]
- Is there an expression for an infinite iterator?
- Cartesian product of a dictionary of lists
- When is not a good time to use python generators?
- How to check if an object is a generator object in python?
- Difference between ‘cls’ and ‘self’ in Python classes?
- python 3 print generator
- Evaluation of boolean expressions in Python
- Python: using a recursive algorithm as a generator
- Getting container/parent object from within python
- Retrieving JSON objects from a text file (using Python)
- What is the purpose of the “send” function on Python generators?
- How to access (get or set) object attribute given string corresponding to name of that attribute
- How to use fit_generator with multiple inputs
- How to create the union of many sets using a generator expression?
- Python object attributes – methodology for access
- Python using exceptions for control flow considered bad?
- How can two Python objects have same id but ‘is’ operator returns False?