python: Better use iterators
In Python 2, iterators had a .next() method. In Python 3, instead they have a .__next__() method, which is automatically called by the next() builtin. In addition, it is better to use the iter() builtin to create an iterator, rather than calling its __iter__() method. These were also introduced in Python 2.6, so using it makes the script compatible with Python 2 and 3. Signed-off-by: Mathieu Bridon <bochecha@daitauha.fr> Reviewed-by: Eric Engestrom <eric.engestrom@intel.com> Reviewed-by: Dylan Baker <dylan@pnwbakers.com>
This commit is contained in:

committed by
Dylan Baker

parent
01da2feb0e
commit
022d2a381d
@@ -62,7 +62,7 @@ class type_signature_iter(object):
|
||||
def __iter__(self):
|
||||
return self
|
||||
|
||||
def next(self):
|
||||
def __next__(self):
|
||||
if self.i < len(self.source_types):
|
||||
i = self.i
|
||||
self.i += 1
|
||||
@@ -76,6 +76,8 @@ class type_signature_iter(object):
|
||||
else:
|
||||
raise StopIteration()
|
||||
|
||||
next = __next__
|
||||
|
||||
|
||||
uint_type = type("unsigned", "u", "GLSL_TYPE_UINT")
|
||||
int_type = type("int", "i", "GLSL_TYPE_INT")
|
||||
|
Reference in New Issue
Block a user