itertools
provides three infinite iterators:
-
count(start=0, step=1)
: 0, 1, 2, 3, 4, … -
cycle(p)
: p[0], p[1], …, p[-1], p[0], … -
repeat(x, times=∞)
: x, x, x, x, …
I don’t know of any others in the standard library.
Since you asked for a one-liner:
__import__("itertools").count()