[Piglit] [PATCH 04/11] profile.py: use dict.iteritems() instead of keys

Dylan Baker baker.dylan.c at gmail.com
Fri Apr 25 13:27:36 PDT 2014


Doing dictionary lookup in a loop using a key is not a pythonic
constuct, use iteritems() to provide both the key and value as names in
the loop.
---
 framework/profile.py | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/framework/profile.py b/framework/profile.py
index ea37f6c..82bf64d 100644
--- a/framework/profile.py
+++ b/framework/profile.py
@@ -75,12 +75,12 @@ class TestProfile(object):
         '''
 
         def f(prefix, group, test_dict):
-            for key in group.iterkeys():
+            for key, value in group.iteritems():
                 fullkey = key if prefix == '' else os.path.join(prefix, key)
-                if isinstance(group[key], dict):
-                    f(fullkey, group[key], test_dict)
+                if isinstance(value, dict):
+                    f(fullkey, value, test_dict)
                 else:
-                    test_dict[fullkey] = group[key]
+                    test_dict[fullkey] = value
         f('', self.tests, self.test_list)
         # Clear out the old Group()
         self.tests = {}
-- 
2.0.0.rc0



More information about the Piglit mailing list