Python Reference (The Right Way)
latest
  • Introduction
  • Definitions
  • Coding Guidelines
  • Fundamental Data Types
  • Built-In Functions
  • Comprehensions and Generator Expression
  • Container Data Access
  • Operators
  • Statements
  • Other Objects
  • Double Underscore Methods and Variables
  • Exceptions
  • Constants
  • Boilerplate
  • Glimpse of the PSL
  • Resources
  • Licence
Python Reference (The Right Way)
  • Docs »
  • next
  • Edit on GitHub

next¶

Description¶

Retrieves the next item from the iterator by calling its next() method.

Syntax¶

next (iterator[, default])

iterator
Required. An iterator object.
default
Optional. This is the value that is returned after retrieving the last item instead of StopIteration error.

Return Value¶

#TODO

Time Complexity¶

#TODO

Example 1¶

>>> i = iter([1, 2])
>>> next(i)
1
>>> next(i)
2
>>> next(i)
Traceback (most recent call last):
  File "<interactive input>", line 1, in <module>
StopIteration

Example 2¶

>>> i = iter([1, 2])
>>> next(i, 'No more items in the list.')
1
>>> next(i, 'No more items in the list.')
2
>>> next(i, 'No more items in the list.')
'No more items in the list.'

See Also¶

#TODO


© Copyright 2015, Jakub Przywóski. Revision 9a3b94e7.

Built with Sphinx using a theme provided by Read the Docs.