summaryrefslogtreecommitdiff
path: root/itertoolset.py
diff options
context:
space:
mode:
Diffstat (limited to 'itertoolset.py')
-rw-r--r--itertoolset.py16
1 files changed, 8 insertions, 8 deletions
diff --git a/itertoolset.py b/itertoolset.py
index 498b940..4d293e8 100644
--- a/itertoolset.py
+++ b/itertoolset.py
@@ -15,16 +15,16 @@ def peek(iterable):
first_element = next(it)
return first_element, chain([first_element], it)
-def repeat_func(func, times=None, args=()):
- "equivalent to (func(*args) for i in xrange(times))."
+def repeatfunc(func, times=None, *args):
+ """Repeat calls to func with specified arguments.
+
+ Example: repeatfunc(random.random)
+ """
if times is None:
- while True:
- yield func(*args)
- else:
- for i in xrange(times):
- yield func(*args)
+ return starmap(func, repeat(args))
+ return starmap(func, repeat(args, times))
-def repeat_copy(object, times=None):
+def repeatcopy(object, times=None):
"""Returns deep copies of `object` over and over again. Runs indefinitely
unless the `times` argument is specified."""
if times is None: