Lets say I have a program that needs to run in both Py 2 and Py 3. The only difference in the functionality is range vs xrange. Is it possible to do something like this?
if version == 3: pass
else: range = xrange
I know I saw something like this before, however I can't seem to find an example on the Google machine. Thanks guys.
sys.version_infotuple if you want to do it manually. Google forsix,python-futureorninefor 3rd party libraries designed to solve this problem.if range is None: range = xrange