In Python 2, if you have an iterator, you can just call its next
method. Something like:
>>> (5*x for x in xrange(2,4)).next()
10
In Python 3, you can use the next
built-in with an iterator:
>>> next(5*x for x in range(2,4))
10
In Python 2, if you have an iterator, you can just call its next
method. Something like:
>>> (5*x for x in xrange(2,4)).next()
10
In Python 3, you can use the next
built-in with an iterator:
>>> next(5*x for x in range(2,4))
10