def copy(self):
# type: () -> IterableWrapper
""" Return an exact copy of the iterable.
The reference of the new iterable will be the same as the source
when `copy()` was called.
Example:
>>> from ww import g
>>> my_g_1 = g(range(3))
>>> my_g_2 = my_g_1.copy()
>>> next(my_g_1)
0
>>> next(my_g_1)
1
>>> next(my_g_2)
0
"""
self.iterator, new = itertools.tee(self.iterator)
return self.__class__(new)
评论列表
文章目录