[Python-Dev] best practices stdlib: purging xrange
"Martin v. Löwis"
martin at v.loewis.de
Wed May 9 06:46:50 CEST 2007
> Just curious why 2to3 would not replace range() with list(range())?
In most usages of range(), using the 3.0 range() will work just as
well, and be more efficient.
If I wanted to write code that works in both versions (which I
understand is not the 2to3 objective), then I would use range().
If I worry about creating a list in 2.x, I would write
try:
xrange
except NameError:
xrange=range
at the top of the file.
Regards,
Martin
More information about the Python-Dev
mailing list