diff options
author | Fred Drake <fdrake@acm.org> | 2004-02-12 14:35:18 (GMT) |
---|---|---|
committer | Fred Drake <fdrake@acm.org> | 2004-02-12 14:35:18 (GMT) |
commit | e6ed33a6b394a7ca1b10eb42833a0e2dd89937d1 (patch) | |
tree | 328418fe79cfbab43522d24741f775927a4ab278 /Doc/tut | |
parent | b1e5b5053113b9c31f864c953e1b178a58891c9f (diff) | |
download | cpython-e6ed33a6b394a7ca1b10eb42833a0e2dd89937d1.zip cpython-e6ed33a6b394a7ca1b10eb42833a0e2dd89937d1.tar.gz cpython-e6ed33a6b394a7ca1b10eb42833a0e2dd89937d1.tar.bz2 |
fix minor markup error: \code{for} --> \keyword{for}
Diffstat (limited to 'Doc/tut')
-rw-r--r-- | Doc/tut/tut.tex | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/Doc/tut/tut.tex b/Doc/tut/tut.tex index 3933fc6..7814231 100644 --- a/Doc/tut/tut.tex +++ b/Doc/tut/tut.tex @@ -4286,7 +4286,7 @@ finally the instance converted to a string using the built-in function \section{Iterators\label{iterators}} By now, you've probably noticed that most container objects can be looped -over using a \code{for} statement: +over using a \keyword{for} statement: \begin{verbatim} for element in [1, 2, 3]: @@ -4302,11 +4302,12 @@ for line in open("myfile.txt"): \end{verbatim} This style of access is clear, concise, and convenient. The use of iterators -pervades and unifies Python. Behind the scenes, the \code{for} statement calls -\function{iter()} on the container object. The function returns an iterator -object that defines the method \method{next()} which accesses elements in the -container one at a time. When there are no more elements, \method{next()} -raises a \exception{StopIteration} exception which tells the \code{for} loop +pervades and unifies Python. Behind the scenes, the \keyword{for} +statement calls \function{iter()} on the container object. The +function returns an iterator object that defines the method +\method{next()} which accesses elements in the container one at a +time. When there are no more elements, \method{next()} raises a +\exception{StopIteration} exception which tells the \keyword{for} loop to terminate. This example shows how it all works: \begin{verbatim} |