I believe you just want six.moves.range
. Not, six.moves.builtins.range
.
>>> # tested on python2.x..
>>> import six.moves as sm
>>> sm.range
<type 'xrange'>
The reason here is that six.moves.builtins
is the version agnostic "builtins" module. That just gives you access to the builtins -- it doesn't actually change what any of the builtins are.
Typically, I don't feel the need to introduce the external dependency in cases like this. I usually just add something like this to the top of my source file:
try:
xrange
except NameError: # python3
xrange = range