Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 00bb329

Browse files
committed
Document the built-in iter() function.
1 parent 7feae2d commit 00bb329

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

Doc/lib/libfuncs.tex

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -390,6 +390,23 @@ \section{Built-in Functions \label{built-in-funcs}}
390390
raised.
391391
\end{funcdesc}
392392

393+
\begin{funcdesc}{iter}{o\optional{, sentinel}}
394+
Return an iterator object. The first argument is interpreted very
395+
differently depending on the presence of the second argument.
396+
Without a second argument, \var{o} must be a collection object which
397+
supports the iteration protocol (the \method{__iter__()} method), or
398+
it must support the sequence protocol (the \method{__getitem__()}
399+
method with integer arguments starting at \code{0}). If it does not
400+
support either of those protocols, \exception{TypeError} is raised.
401+
If the second argument, \var{sentinel}, is given, then \var{o} must
402+
be a callable object. The iterator created in this case will call
403+
\var{o} with no arguments for each call to its \method{next()}
404+
method; if the value returned is equal to \var{sentinel},
405+
\exception{StopIteration} will be raised, otherwise the value will
406+
be returned.
407+
\versionadded{2.2}
408+
\end{funcdesc}
409+
393410
\begin{funcdesc}{len}{s}
394411
Return the length (the number of items) of an object. The argument
395412
may be a sequence (string, tuple or list) or a mapping (dictionary).

0 commit comments

Comments
 (0)