l = range(int(1E9))
Michael Torrie
torriem at gmail.com
Sat May 2 22:07:31 EDT 2015
On 05/02/2015 04:33 PM, BartC wrote:
> OK, so it's just an irritation then, as a workaround has been available
> for a long time. (For example, if you use xrange, it won't work on 3.x.
> If you use range, then it might be inefficient on 2.x.)
In both Python 2.7 and 3.3+, you can use the 3rd-party six module to
help with forward compatibility:
from six.moves import xrange
In Python 2.7, it's just the normal xrange (importing is a no op
basically), but in Python 3 it points to range.
Kind of wish parts of six were in the Python standard library.
More information about the Python-list
mailing list