diff options
author | Ezio Melotti <ezio.melotti@gmail.com> | 2012-10-12 10:46:37 (GMT) |
---|---|---|
committer | Ezio Melotti <ezio.melotti@gmail.com> | 2012-10-12 10:46:37 (GMT) |
commit | 5c3283e43a13885948af2acd582a1cb801d67560 (patch) | |
tree | d90e64f59a41a2a79e339ef1f9aaa79d857dcace /Doc/reference | |
parent | 9054055857bafb00719b83898ca5b02d212a54fa (diff) | |
parent | 1dd7c304194572c3c5e6fd943bc0aac49a4c481c (diff) | |
download | cpython-5c3283e43a13885948af2acd582a1cb801d67560.zip cpython-5c3283e43a13885948af2acd582a1cb801d67560.tar.gz cpython-5c3283e43a13885948af2acd582a1cb801d67560.tar.bz2 |
Merge __next__ method link fixes with 3.3.
Diffstat (limited to 'Doc/reference')
-rw-r--r-- | Doc/reference/datamodel.rst | 6 | ||||
-rw-r--r-- | Doc/reference/expressions.rst | 23 |
2 files changed, 15 insertions, 14 deletions
diff --git a/Doc/reference/datamodel.rst b/Doc/reference/datamodel.rst index aebdf40..beeaf83 100644 --- a/Doc/reference/datamodel.rst +++ b/Doc/reference/datamodel.rst @@ -600,9 +600,9 @@ Callable types A function or method which uses the :keyword:`yield` statement (see section :ref:`yield`) is called a :dfn:`generator function`. Such a function, when called, always returns an iterator object which can be used to execute the - body of the function: calling the iterator's :meth:`__next__` method will - cause the function to execute until it provides a value using the - :keyword:`yield` statement. When the function executes a + body of the function: calling the iterator's :meth:`iterator__next__` + method will cause the function to execute until it provides a value + using the :keyword:`yield` statement. When the function executes a :keyword:`return` statement or falls off the end, a :exc:`StopIteration` exception is raised and the iterator will have reached the end of the set of values to be returned. diff --git a/Doc/reference/expressions.rst b/Doc/reference/expressions.rst index 364135a..41523cb 100644 --- a/Doc/reference/expressions.rst +++ b/Doc/reference/expressions.rst @@ -294,13 +294,13 @@ for comprehensions, except that it is enclosed in parentheses instead of brackets or curly braces. Variables used in the generator expression are evaluated lazily when the -:meth:`__next__` method is called for generator object (in the same fashion as -normal generators). However, the leftmost :keyword:`for` clause is immediately -evaluated, so that an error produced by it can be seen before any other possible -error in the code that handles the generator expression. Subsequent -:keyword:`for` clauses cannot be evaluated immediately since they may depend on -the previous :keyword:`for` loop. For example: ``(x*y for x in range(10) for y -in bar(x))``. +:meth:`~generator.__next__` method is called for generator object (in the same +fashion as normal generators). However, the leftmost :keyword:`for` clause is +immediately evaluated, so that an error produced by it can be seen before any +other possible error in the code that handles the generator expression. +Subsequent :keyword:`for` clauses cannot be evaluated immediately since they +may depend on the previous :keyword:`for` loop. For example: ``(x*y for x in +range(10) for y in bar(x))``. The parentheses can be omitted on calls with only one argument. See section :ref:`calls` for the detail. @@ -394,10 +394,11 @@ is already executing raises a :exc:`ValueError` exception. Starts the execution of a generator function or resumes it at the last executed :keyword:`yield` expression. When a generator function is resumed - with a :meth:`__next__` method, the current :keyword:`yield` expression - always evaluates to :const:`None`. The execution then continues to the next - :keyword:`yield` expression, where the generator is suspended again, and the - value of the :token:`expression_list` is returned to :meth:`next`'s caller. + with a :meth:`~generator.__next__` method, the current :keyword:`yield` + expression always evaluates to :const:`None`. The execution then continues + to the next :keyword:`yield` expression, where the generator is suspended + again, and the value of the :token:`expression_list` is returned to + :meth:`next`'s caller. If the generator exits without yielding another value, a :exc:`StopIteration` exception is raised. |