| 1 |
============= |
| 2 |
API Reference |
| 3 |
============= |
| 4 |
|
| 5 |
.. automodule:: more_itertools |
| 6 |
|
| 7 |
Grouping |
| 8 |
======== |
| 9 |
|
| 10 |
These tools yield groups of items from a source iterable. |
| 11 |
|
| 12 |
---- |
| 13 |
|
| 14 |
**New itertools** |
| 15 |
|
| 16 |
.. autofunction:: chunked |
| 17 |
.. autofunction:: sliced |
| 18 |
.. autofunction:: distribute |
| 19 |
.. autofunction:: divide |
| 20 |
.. autofunction:: split_at |
| 21 |
.. autofunction:: split_before |
| 22 |
.. autofunction:: split_after |
| 23 |
.. autofunction:: bucket |
| 24 |
|
| 25 |
---- |
| 26 |
|
| 27 |
**Itertools recipes** |
| 28 |
|
| 29 |
.. autofunction:: grouper |
| 30 |
.. autofunction:: partition |
| 31 |
|
| 32 |
|
| 33 |
Lookahead and lookback |
| 34 |
====================== |
| 35 |
|
| 36 |
These tools peek at an iterable's values without advancing it. |
| 37 |
|
| 38 |
---- |
| 39 |
|
| 40 |
**New itertools** |
| 41 |
|
| 42 |
|
| 43 |
.. autofunction:: spy |
| 44 |
.. autoclass:: peekable |
| 45 |
.. autoclass:: seekable |
| 46 |
|
| 47 |
|
| 48 |
Windowing |
| 49 |
========= |
| 50 |
|
| 51 |
These tools yield windows of items from an iterable. |
| 52 |
|
| 53 |
---- |
| 54 |
|
| 55 |
**New itertools** |
| 56 |
|
| 57 |
.. autofunction:: windowed |
| 58 |
.. autofunction:: stagger |
| 59 |
|
| 60 |
---- |
| 61 |
|
| 62 |
**Itertools recipes** |
| 63 |
|
| 64 |
.. autofunction:: pairwise |
| 65 |
|
| 66 |
|
| 67 |
Augmenting |
| 68 |
========== |
| 69 |
|
| 70 |
These tools yield items from an iterable, plus additional data. |
| 71 |
|
| 72 |
---- |
| 73 |
|
| 74 |
**New itertools** |
| 75 |
|
| 76 |
.. autofunction:: count_cycle |
| 77 |
.. autofunction:: intersperse |
| 78 |
.. autofunction:: padded |
| 79 |
.. autofunction:: adjacent |
| 80 |
.. autofunction:: groupby_transform |
| 81 |
|
| 82 |
---- |
| 83 |
|
| 84 |
**Itertools recipes** |
| 85 |
|
| 86 |
.. autofunction:: padnone |
| 87 |
.. autofunction:: ncycles |
| 88 |
|
| 89 |
|
| 90 |
Combining |
| 91 |
========= |
| 92 |
|
| 93 |
These tools combine multiple iterables. |
| 94 |
|
| 95 |
---- |
| 96 |
|
| 97 |
**New itertools** |
| 98 |
|
| 99 |
.. autofunction:: collapse |
| 100 |
.. autofunction:: sort_together |
| 101 |
.. autofunction:: interleave |
| 102 |
.. autofunction:: interleave_longest |
| 103 |
.. autofunction:: collate(*iterables, key=lambda a: a, reverse=False) |
| 104 |
.. autofunction:: zip_offset(*iterables, offsets, longest=False, fillvalue=None) |
| 105 |
|
| 106 |
---- |
| 107 |
|
| 108 |
**Itertools recipes** |
| 109 |
|
| 110 |
.. autofunction:: dotproduct |
| 111 |
.. autofunction:: flatten |
| 112 |
.. autofunction:: roundrobin |
| 113 |
.. autofunction:: prepend |
| 114 |
|
| 115 |
|
| 116 |
Summarizing |
| 117 |
=========== |
| 118 |
|
| 119 |
These tools return summarized or aggregated data from an iterable. |
| 120 |
|
| 121 |
---- |
| 122 |
|
| 123 |
**New itertools** |
| 124 |
|
| 125 |
.. autofunction:: ilen |
| 126 |
.. autofunction:: first(iterable[, default]) |
| 127 |
.. autofunction:: one |
| 128 |
.. autofunction:: unique_to_each |
| 129 |
.. autofunction:: locate(iterable, pred=bool) |
| 130 |
.. autofunction:: consecutive_groups(iterable, ordering=lambda x: x) |
| 131 |
.. autofunction:: exactly_n(iterable, n, predicate=bool) |
| 132 |
.. autoclass:: run_length |
| 133 |
.. autofunction:: map_reduce |
| 134 |
|
| 135 |
---- |
| 136 |
|
| 137 |
**Itertools recipes** |
| 138 |
|
| 139 |
.. autofunction:: all_equal |
| 140 |
.. autofunction:: first_true |
| 141 |
.. autofunction:: nth |
| 142 |
.. autofunction:: quantify(iterable, pred=bool) |
| 143 |
|
| 144 |
|
| 145 |
Selecting |
| 146 |
========= |
| 147 |
|
| 148 |
These tools yield certain items from an iterable. |
| 149 |
|
| 150 |
---- |
| 151 |
|
| 152 |
**New itertools** |
| 153 |
|
| 154 |
.. autofunction:: islice_extended(start, stop, step) |
| 155 |
.. autofunction:: strip |
| 156 |
.. autofunction:: lstrip |
| 157 |
.. autofunction:: rstrip |
| 158 |
|
| 159 |
---- |
| 160 |
|
| 161 |
**Itertools recipes** |
| 162 |
|
| 163 |
.. autofunction:: take |
| 164 |
.. autofunction:: tail |
| 165 |
.. autofunction:: unique_everseen |
| 166 |
.. autofunction:: unique_justseen |
| 167 |
|
| 168 |
|
| 169 |
Combinatorics |
| 170 |
============= |
| 171 |
|
| 172 |
These tools yield combinatorial arrangements of items from iterables. |
| 173 |
|
| 174 |
---- |
| 175 |
|
| 176 |
**New itertools** |
| 177 |
|
| 178 |
.. autofunction:: distinct_permutations |
| 179 |
.. autofunction:: circular_shifts |
| 180 |
|
| 181 |
---- |
| 182 |
|
| 183 |
**Itertools recipes** |
| 184 |
|
| 185 |
.. autofunction:: powerset |
| 186 |
.. autofunction:: random_product |
| 187 |
.. autofunction:: random_permutation |
| 188 |
.. autofunction:: random_combination |
| 189 |
.. autofunction:: random_combination_with_replacement |
| 190 |
.. autofunction:: nth_combination |
| 191 |
|
| 192 |
|
| 193 |
Wrapping |
| 194 |
======== |
| 195 |
|
| 196 |
These tools provide wrappers to smooth working with objects that produce or |
| 197 |
consume iterables. |
| 198 |
|
| 199 |
---- |
| 200 |
|
| 201 |
**New itertools** |
| 202 |
|
| 203 |
.. autofunction:: always_iterable |
| 204 |
.. autofunction:: consumer |
| 205 |
.. autofunction:: with_iter |
| 206 |
|
| 207 |
---- |
| 208 |
|
| 209 |
**Itertools recipes** |
| 210 |
|
| 211 |
.. autofunction:: iter_except |
| 212 |
|
| 213 |
|
| 214 |
Others |
| 215 |
====== |
| 216 |
|
| 217 |
**New itertools** |
| 218 |
|
| 219 |
.. autofunction:: numeric_range(start, stop, step) |
| 220 |
.. autofunction:: always_reversible |
| 221 |
.. autofunction:: side_effect |
| 222 |
.. autofunction:: iterate |
| 223 |
.. autofunction:: difference(iterable, func=operator.sub) |
| 224 |
.. autofunction:: make_decorator |
| 225 |
.. autoclass:: SequenceView |
| 226 |
|
| 227 |
---- |
| 228 |
|
| 229 |
**Itertools recipes** |
| 230 |
|
| 231 |
.. autofunction:: consume |
| 232 |
.. autofunction:: accumulate(iterable, func=operator.add) |
| 233 |
.. autofunction:: tabulate |
| 234 |
.. autofunction:: repeatfunc |