As range() returns the list, all the operations that can be applied on the list can be used on it. On the other hand, as xrange() returns the xrange object, operations associated to list cannot be applied on them, hence a disadvantage.
import six.moves as sm
for i in sm.xrange(1)[::-1]:
print("test i: {}".format(i))
In python 2, it throws the error:
TypeError: sequence index must be integer, not 'slice'
https://six.readthedocs.io/#module-six.moves (Renamed modules and attributes compatibility)
range
insix.moves
refers to xrange in python 2 and range in python 3In my opinion,
range(self.GetColumnCount())[::-1]
is not a proper usage. Though this works in python 3 but it crashes in python 2.https://www.geeksforgeeks.org/range-vs-xrange-python/ This webpage explains the use of xrange.
In python 2, it throws the error:
TypeError: sequence index must be integer, not 'slice'