In Python <= 2.5, use gen.next() . This will work for all versions of Python 2.x, but not Python 3.x
In Python> = 2.6, use next(gen) . This is a built-in function and is understandable. It will also work on Python 3.
Both of them ultimately call the specially named function next() , which can be overridden by subclassification. However, in Python 3, this function was renamed to __next__() to match other special functions.
Christian Oudard Mar 10 2018-10-10T00: 00Z
source share