Modernize use of range()

In Python 3, range() behaves like the old xrange().
The difference between range() and xrange() is usually not significant,
especially if the whole result is iterated over.

Convert xrange() usage to range() for small ranges.
Use modern idioms in a few other uses of range().

Reviewed-By: Christian Heimes <cheimes@redhat.com>
Reviewed-By: Jan Cholasta <jcholast@redhat.com>
This commit is contained in:
Petr Viktorin
2015-08-12 15:23:56 +02:00
committed by Jan Cholasta
parent 9e917cae39
commit 5178e9a597
22 changed files with 45 additions and 46 deletions

View File

@@ -33,8 +33,8 @@ def entry_to_update(entry):
update = []
for attr in entry.keys():
if isinstance(entry[attr], list):
for i in xrange(len(entry[attr])):
update.append(dict(attr=str(attr), value=str(entry[attr][i])))
for item in entry[attr]:
update.append(dict(attr=str(attr), value=str(item)))
else:
update.append(dict(attr=str(attr), value=str(entry[attr])))