Skip to main content

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

NameTypeDescription
ititerableThe iterable or generator to be converted into a reusable collection.

Returns

TypeDescription
iterableThe original input if it is a list or tuple, otherwise a cached wrapper that allows multiple iterations over the generator's contents.