mcfletch / runsnakerun

RunSnakeRun python profiling GUI front-end
Other
31 stars 6 forks source link

Fixing issue #2 related to usage of six.moves.range #5

Open kaushikacharya opened 4 years ago

kaushikacharya commented 4 years ago

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'