I think you should just use `from six.moves import xrange` (together with other imports).