[Python-Dev] best practices stdlib: purging xrange (original) (raw)
"Martin v. Löwis" martin at v.loewis.de
Wed May 9 06:46:50 CEST 2007
- Previous message: [Python-Dev] best practices stdlib: purging xrange
- Next message: [Python-Dev] best practices stdlib: purging xrange
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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
- Previous message: [Python-Dev] best practices stdlib: purging xrange
- Next message: [Python-Dev] best practices stdlib: purging xrange
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]