[Mesa-dev] [PATCH 18/41] glapi: gl_XML.py: use python's iter() function rather than calling __iter__

Dylan Baker baker.dylan.c at gmail.com
Fri Apr 1 00:04:35 UTC 2016

Python has what are often referred to as "magic methods". __iter__,
__str__, __add__, and countless more. All of these methods exist to be
called by another function or by an operator. The __add__ method
implements the + operator, for example.

There are times to call the magic methods directly, but usually that's
in cases where an implementation needs to call it's parent's method.
Instead it's best to use the function or operator that the magic method

This makes the code cleaner, more idiomatic, and just a bit nicer to

Signed-off-by: Dylan Baker <dylanx.c.baker at intel.com>
 src/mapi/glapi/gen/gl_XML.py | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/src/mapi/glapi/gen/gl_XML.py b/src/mapi/glapi/gen/gl_XML.py
index d273ff0..42fcc41 100644
--- a/src/mapi/glapi/gen/gl_XML.py
+++ b/src/mapi/glapi/gen/gl_XML.py
@@ -734,9 +734,9 @@ class gl_function(gl_item):
     def parameterIterator(self, name=None):
         if name is not None:
-            return self.entry_point_parameters[name].__iter__()
+            return iter(self.entry_point_parameters[name])
-            return self.parameters.__iter__()
+            return iter(self.parameters)
     def get_parameter_string(self, entrypoint=None):
         if entrypoint:
@@ -935,7 +935,7 @@ class gl_api(object):
                 for name in names:
-        return functions.__iter__()
+        return iter(functions)
     def functionIterateByOffset(self):
         max_offset = -1
@@ -953,7 +953,7 @@ class gl_api(object):
             if temp[i]:
-        return list.__iter__()
+        return iter(list)
     def functionIterateAll(self):
         return self.functions_by_name.itervalues()
@@ -966,7 +966,7 @@ class gl_api(object):
         for enum in keys:
-        return list.__iter__()
+        return iter(list)
     def categoryIterate(self):
         """Iterate over categories.
@@ -983,7 +983,7 @@ class gl_api(object):
             for key in keys:
-        return list.__iter__()
+        return iter(list)
     def get_category_for_name(self, name):
         if name in self.category_dict:

More information about the mesa-dev mailing list