def __mul__(self, num):
# type: (int) -> IterableWrapper
""" Duplicate itself and concatenate the results.
It's basically a shortcut for `g().chain(*g().tee())`.
Args:
num: The number of times to duplicate.
Example:
>>> from ww import g
>>> (g(range(3)) * 3).list()
[0, 1, 2, 0, 1, 2, 0, 1, 2]
>>> (2 * g(range(3))).list()
[0, 1, 2, 0, 1, 2]
"""
clones = itertools.tee(self.iterator, num)
return self.__class__(itertools.chain(*clones))
评论列表
文章目录