diff options
author | Anthony LaTorre <tlatorre9@gmail.com> | 2011-08-26 18:57:02 -0400 |
---|---|---|
committer | Anthony LaTorre <tlatorre9@gmail.com> | 2011-08-26 18:57:02 -0400 |
commit | 41ffc05d05bfa3849c8160dd7cfa95b1eb51bb61 (patch) | |
tree | bdc94d75919b69af03604b6efee292407ec9c361 | |
parent | 28182873d1c8a8e1d3de38e3a4440490680683c5 (diff) | |
download | chroma-41ffc05d05bfa3849c8160dd7cfa95b1eb51bb61.tar.gz chroma-41ffc05d05bfa3849c8160dd7cfa95b1eb51bb61.tar.bz2 chroma-41ffc05d05bfa3849c8160dd7cfa95b1eb51bb61.zip |
cleanup repeating_iterator() docstring.
-rw-r--r-- | itertoolset.py | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/itertoolset.py b/itertoolset.py index eb96e74..2d71d0c 100644 --- a/itertoolset.py +++ b/itertoolset.py @@ -3,20 +3,21 @@ import collections from copy import deepcopy def repeating_iterator(i, nreps): - '''Returns an iterator that emits each element of `i` multiple times specified by `nreps`. - The length of this iterator is the lenght of `i` times `nreps`. This iterator - is safe even if the item consumer modifies the items. + """Returns an iterator that emits each element of `i` multiple times + specified by `nreps`. The length of this iterator is the lenght of `i` + times `nreps`. This iterator is safe even if the item consumer modifies + the items. - >>> list(repeating_iterator('ABCD', 3) - ['A', 'A', 'A', 'B', 'B', 'B', 'C', 'C', 'C', 'D', 'D', 'D'] - >>> list(repeating_iterator('ABCD', 1) - ['A', 'B', 'C', 'D'] - ''' + Examples: + >>> list(repeating_iterator('ABCD', 3) + ['A', 'A', 'A', 'B', 'B', 'B', 'C', 'C', 'C', 'D', 'D', 'D'] + >>> list(repeating_iterator('ABCD', 1) + ['A', 'B', 'C', 'D'] + """ for item in i: for counter in xrange(nreps): yield deepcopy(item) - def grouper(n, iterable, fillvalue=None): "grouper(3, 'ABCDEFG', 'x') --> ABC DEF Gxx" args = [iter(iterable)] * n |