Convert iterator to an object that can be consumed multiple times. ``Regen`` takes any iterable, and if the object is an generator it will cache the evaluated list on first access, so that the generator can be "consumed" multiple times.
(it)
| 180 | |
| 181 | |
| 182 | def regen(it): |
| 183 | """Convert iterator to an object that can be consumed multiple times. |
| 184 | |
| 185 | ``Regen`` takes any iterable, and if the object is an |
| 186 | generator it will cache the evaluated list on first access, |
| 187 | so that the generator can be "consumed" multiple times. |
| 188 | """ |
| 189 | if isinstance(it, (list, tuple)): |
| 190 | return it |
| 191 | return _regen(it) |
| 192 | |
| 193 | |
| 194 | class _regen(UserList, list): |