[issue7721] Code in xrange documentation does not work

Florent Xicluna report at bugs.python.org
Sun Jan 17 01:33:51 CET 2010


Florent Xicluna <laxyf at yahoo.fr> added the comment:

You will prefer this one. It is as fast as the 2.7 version.
The restrictions are described in the itertools documentation.


from itertools import count, takewhile
irange = lambda start, stop, step: takewhile(lambda x: x<stop, (start+i*step for i in count()))

>>> list(irange(-2**65,2**65,2**61))
[-36893488147419103232L, ...

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue7721>
_______________________________________


More information about the Python-bugs-list mailing list