[Python-checkins] cpython (3.3): #16557: update functional howto -- "return value" is valid after PEP 380.

ezio.melotti python-checkins at python.org
Sun Jan 20 15:35:25 CET 2013


http://hg.python.org/cpython/rev/e0de6e6e992e
changeset:   81613:e0de6e6e992e
branch:      3.3
parent:      81611:572ca3d35c2f
user:        Ezio Melotti <ezio.melotti at gmail.com>
date:        Sun Jan 20 16:34:21 2013 +0200
summary:
  #16557: update functional howto -- "return value" is valid after PEP 380.  Initial patch by Ramchandra Apte.

files:
  Doc/howto/functional.rst |  11 ++++-------
  1 files changed, 4 insertions(+), 7 deletions(-)


diff --git a/Doc/howto/functional.rst b/Doc/howto/functional.rst
--- a/Doc/howto/functional.rst
+++ b/Doc/howto/functional.rst
@@ -479,13 +479,10 @@
 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

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list