summaryrefslogtreecommitdiffstats
path: root/Doc/ref/ref6.tex
diff options
context:
space:
mode:
authorGeorg Brandl <georg@python.org>2007-04-21 15:47:16 (GMT)
committerGeorg Brandl <georg@python.org>2007-04-21 15:47:16 (GMT)
commita18af4e7a2091d11478754eb66ae387a85535763 (patch)
treefea8015d656cfee937bb6f3d106e6ca0e9f19d78 /Doc/ref/ref6.tex
parent4d2adcca52ced412d4bdf131b872729c43520d58 (diff)
downloadcpython-a18af4e7a2091d11478754eb66ae387a85535763.zip
cpython-a18af4e7a2091d11478754eb66ae387a85535763.tar.gz
cpython-a18af4e7a2091d11478754eb66ae387a85535763.tar.bz2
PEP 3114: rename .next() to .__next__() and add next() builtin.
Diffstat (limited to 'Doc/ref/ref6.tex')
-rw-r--r--Doc/ref/ref6.tex25
1 files changed, 12 insertions, 13 deletions
diff --git a/Doc/ref/ref6.tex b/Doc/ref/ref6.tex
index 4c7487b..e92a63d 100644
--- a/Doc/ref/ref6.tex
+++ b/Doc/ref/ref6.tex
@@ -418,19 +418,18 @@ Using a \keyword{yield} statement in a function definition is
sufficient to cause that definition to create a generator function
instead of a normal function.
-When a generator function is called, it returns an iterator known as a
-generator iterator, or more commonly, a generator. The body of the
-generator function is executed by calling the generator's
-\method{next()} method repeatedly until it raises an exception.
-
-When a \keyword{yield} statement is executed, the state of the
-generator is frozen and the value of \grammartoken{expression_list} is
-returned to \method{next()}'s caller. By ``frozen'' we mean that all
-local state is retained, including the current bindings of local
-variables, the instruction pointer, and the internal evaluation stack:
-enough information is saved so that the next time \method{next()} is
-invoked, the function can proceed exactly as if the \keyword{yield}
-statement were just another external call.
+When a generator function is called, it returns an iterator known as a generator
+iterator, or more commonly, a generator. The body of the generator function is
+executed by calling the generator's \method{__next__()} method repeatedly until
+it raises an exception.
+
+When a \keyword{yield} statement is executed, the state of the generator is
+frozen and the value of \grammartoken{expression_list} is returned to
+\method{__next__()}'s caller. By ``frozen'' we mean that all local state is
+retained, including the current bindings of local variables, the instruction
+pointer, and the internal evaluation stack: enough information is saved so that
+the next time \method{__next__()} is invoked, the function can proceed exactly
+as if the \keyword{yield} statement were just another external call.
As of Python version 2.5, the \keyword{yield} statement is now
allowed in the \keyword{try} clause of a \keyword{try} ...\