Is there an expression for an infinite iterator?

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()

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)