regen
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.
def regen(
it: iterable
) - > iterable
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.
Parameters
| Name | Type | Description |
|---|---|---|
| it | iterable | The iterable or generator to be converted into a reusable collection. |
Returns
| Type | Description |
|---|---|
iterable | The original input if it is a list or tuple, otherwise a cached wrapper that allows multiple iterations over the generator's contents. |