Skip to content

Conversation

@kaushikacharya
Copy link

https://six.readthedocs.io/#module-six.moves (Renamed modules and attributes compatibility)
range in six.moves refers to xrange in python 2 and range in python 3

In 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.

Operations usage

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'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant