summaryrefslogtreecommitdiffstats
path: root/Doc
diff options
context:
space:
mode:
authorEzio Melotti <ezio.melotti@gmail.com>2013-01-20 14:35:09 (GMT)
committerEzio Melotti <ezio.melotti@gmail.com>2013-01-20 14:35:09 (GMT)
commitc7ca59a8aeac0cfcc87dc9a90795ded161f92ed1 (patch)
tree9fde2cc330d95e6ae348f90e68e65964d992a198 /Doc
parent60a64d7cbbd61180d602ae4b6f8b16da50ec32ab (diff)
parent5246f66e5e2ac8dc04871f7060235e1d70767458 (diff)
downloadcpython-c7ca59a8aeac0cfcc87dc9a90795ded161f92ed1.zip
cpython-c7ca59a8aeac0cfcc87dc9a90795ded161f92ed1.tar.gz
cpython-c7ca59a8aeac0cfcc87dc9a90795ded161f92ed1.tar.bz2
#16557: merge with 3.3.
Diffstat (limited to 'Doc')
-rw-r--r--Doc/howto/functional.rst11
1 files changed, 4 insertions, 7 deletions
diff --git a/Doc/howto/functional.rst b/Doc/howto/functional.rst
index b621a84..d241f1a 100644
--- a/Doc/howto/functional.rst
+++ b/Doc/howto/functional.rst
@@ -479,13 +479,10 @@ Here's a sample usage of the ``generate_ints()`` generator:
You could equally write ``for i in generate_ints(5)``, or ``a,b,c =
generate_ints(3)``.
-Inside a generator function, the ``return`` statement can only be used without a
-value, and signals the end of the procession of values; after executing a
-``return`` the generator cannot return any further values. ``return`` with a
-value, such as ``return 5``, is a syntax error inside a generator function. The
-end of the generator's results can also be indicated by raising
-:exc:`StopIteration` manually, or by just letting the flow of execution fall off
-the bottom of the function.
+Inside a generator function, ``return value`` is semantically equivalent to
+``raise StopIteration(value)``. If no value is returned or the bottom of the
+function is reached, the procession of values ends and the generator cannot
+return any further values.
You could achieve the effect of generators manually by writing your own class
and storing all the local variables of the generator as instance variables. For