libb.infinite_iterator

infinite_iterator(iterable)[source]

Create an iterator that cycles infinitely through items.

Parameters:

iterable – Sequence to cycle through.

Returns:

Generator that cycles forever.

Example:

>>> ii = infinite_iterator([1,2,3,4,5])
>>> [next(ii) for i in range(9)]
[1, 2, 3, 4, 5, 1, 2, 3, 4]