next | previous | forward | backward | up | top | index | toc | Macaulay2 website
Python :: next

next -- retrieve the next item from a python iterator

Synopsis

Description

This function works just like its Python counterpart. In particular, it retrieves the next item from an iterator.

i1 : x = rs "range(3)"

o1 = range(0, 3)

o1 : PythonObject of class range
i2 : i = iter x

o2 = <range_iterator object at 0x7f0362acf0f0>

o2 : PythonObject of class range_iterator
i3 : next i

o3 = 0

o3 : PythonObject of class int
i4 : next i

o4 = 1

o4 : PythonObject of class int
i5 : next i

o5 = 2

o5 : PythonObject of class int

When the iterator is exhausted, null is returned.

i6 : next i === null

o6 = true

See also

Ways to use next :

For the programmer

The object next is a method function.