On 03/05/2015 03:07, Michael Torrie wrote:
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.


Links to other useful third party modules are given here https://docs.python.org/3/howto/pyporting.html

I doubt that six will ever make the standard library as 2.7 only has another five years in official support. By that time I suppose we'll to going through the porting pain all over again with the transition from Python 3 to Python 4. Alright, alright, only joking :)

--
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.

Mark Lawrence

--
https://mail.python.org/mailman/listinfo/python-list

Reply via email to