I noticed that Python2.6 added a next() to it's list of global functions.
Retrieve the next item from the iterator by calling its next() method.
If
default
is given, it is returned if the iterator is exhausted, otherwiseStopIteration
is raised.
What was the motivation for adding this?
What can you do with next(iterator)
that you can't do with iterator.next()
and an except
clause to handle the StopIteration?