diff options
author | Stan Seibert <stan@mtrr.org> | 2011-09-13 16:10:04 -0400 |
---|---|---|
committer | Stan Seibert <stan@mtrr.org> | 2011-09-13 16:10:04 -0400 |
commit | 4ab542a6f7e8dfbe6aeec2eb1b71176e2e851e75 (patch) | |
tree | 90a910177777115b6ef7ad2780b09ca69ff87109 /itertoolset.py | |
parent | 1ed35a8420b73afa76c12c82f4aebc31132650d9 (diff) | |
parent | 6f0703602270d03f4025221f13fee21aa842a863 (diff) | |
download | chroma-4ab542a6f7e8dfbe6aeec2eb1b71176e2e851e75.tar.gz chroma-4ab542a6f7e8dfbe6aeec2eb1b71176e2e851e75.tar.bz2 chroma-4ab542a6f7e8dfbe6aeec2eb1b71176e2e851e75.zip |
merge
Diffstat (limited to 'itertoolset.py')
-rw-r--r-- | itertoolset.py | 16 |
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: |