Is there an unbounded version of range (or xrange for Python 2), or is it necessary to define it manually? For example
range
xrange
squares = (
You're describing the basic use of itertools.count:
import itertools squares = (x*x for x in itertools.count())