diff --git a/Doc/library/functions.rst b/Doc/library/functions.rst index bad9848602d..427f864a37a 100644 --- a/Doc/library/functions.rst +++ b/Doc/library/functions.rst @@ -596,6 +596,25 @@ available. They are listed here in alphabetical order. its :meth:`next` method; if the value returned is equal to *sentinel*, :exc:`StopIteration` will be raised, otherwise the value will be returned. + Example usage: :: + + >>> iterator = iter(range(10)) + >>> iterator + + >>> iterator.next() + 0 + >>> iterator.next() + 1 + >>> def my_generator(): + ... for i in range(10): + ... yield i + ... + >>> iterator = iter(my_generator().next, 7) + >>> iterator + + >>> list(iterator) + [0, 1, 2, 3, 4, 5, 6] + .. versionadded:: 2.2