Remove xrange for run both Python 2 and Python 3

In python 3, range() does what xrange() used to do and xrange() does not
exist. If you want to write code that will run on both Python 2 and
Python 3, you can't use xrange().

range() can actually be faster in some cases - eg. if iterating over the
same sequence multiple times. xrange() has to reconstruct the integer
object every time, but range() will have real integer objects.
(It will always perform worse in terms of memory however)

xrange() isn't usable in all cases where a real list is needed.
For instance, it doesn't support slices, or any list methods.

Change-Id: Ic08a009e4c8a57f8e958d80d22232f4ceb963b84
This commit is contained in:
Luong Anh Tuan 2016-10-12 11:54:37 +07:00
parent ded68dd775
commit 1588b4111b

View File

@ -446,7 +446,7 @@ class TestIps(unittest.TestCase):
mock_open = mock.mock_open()
for i in xrange(0, 99):
for i in range(0, 99):
# tearDown is ineffective for this loop, so clean the USED_IPs
# on each run
inventory = None