Python 2: someIterator.next() vs. next(someIterator) :Python 3
问题 In Python 2 iterators offer .next() , a callable method: it = iter(xrange(10)) it.next() > 0 it.next() > 1 ... In Python 3 one has to use the built-in function next() : it = iter(range(10)) next(it) > 0 next(it) > 1 ... Is this just "syntactic sugar"? Like making it more obvious to use next() by moving it into the built-in functions? Or does any advanced concept hide behind this change? 回答1: You are directly asking about PEP 3114 consider the following code: class test: def __iter__(self):