I have a python library in which I have frequently used the following type of code
for i in range(...):
# code
Now I know that for larger values, range will be a monster.
Hence I want to use xrange instead of range, but at the same time, I do not wish to replace the word "range" with anything else in the lib and wants it to be compatible with python 2.7 and 3.x.
This is the current implementation:
try:
range = xrange
except NameError:
pass
Now I have two questions.
Thanks.