summaryrefslogtreecommitdiffstats
path: root/Doc/tutorial
diff options
context:
space:
mode:
authorEzio Melotti <ezio.melotti@gmail.com>2012-10-12 10:45:38 (GMT)
committerEzio Melotti <ezio.melotti@gmail.com>2012-10-12 10:45:38 (GMT)
commit1dd7c304194572c3c5e6fd943bc0aac49a4c481c (patch)
tree8ccaddd376941640718f3795c098d5a6b515dac4 /Doc/tutorial
parenteb818193b3445f592b26804b2030fff81625e116 (diff)
parent7fa822275bb9744440f1636345319feaf1669126 (diff)
downloadcpython-1dd7c304194572c3c5e6fd943bc0aac49a4c481c.zip
cpython-1dd7c304194572c3c5e6fd943bc0aac49a4c481c.tar.gz
cpython-1dd7c304194572c3c5e6fd943bc0aac49a4c481c.tar.bz2
Merge __next__ method link fixes with 3.2.
Diffstat (limited to 'Doc/tutorial')
-rw-r--r--Doc/tutorial/classes.rst18
1 files changed, 9 insertions, 9 deletions
diff --git a/Doc/tutorial/classes.rst b/Doc/tutorial/classes.rst
index b4f09c2..3283e54 100644
--- a/Doc/tutorial/classes.rst
+++ b/Doc/tutorial/classes.rst
@@ -737,11 +737,11 @@ using a :keyword:`for` statement::
This style of access is clear, concise, and convenient. The use of iterators
pervades and unifies Python. Behind the scenes, the :keyword:`for` statement
calls :func:`iter` on the container object. The function returns an iterator
-object that defines the method :meth:`__next__` which accesses elements in the
-container one at a time. When there are no more elements, :meth:`__next__`
-raises a :exc:`StopIteration` exception which tells the :keyword:`for` loop to
-terminate. You can call the :meth:`__next__` method using the :func:`next`
-built-in function; this example shows how it all works::
+object that defines the method :meth:`~iterator.__next__` which accesses
+elements in the container one at a time. When there are no more elements,
+:meth:`__next__` raises a :exc:`StopIteration` exception which tells the
+:keyword:`for` loop to terminate. You can call the :meth:`__next__` method
+using the :func:`next` built-in function; this example shows how it all works::
>>> s = 'abc'
>>> it = iter(s)
@@ -761,8 +761,8 @@ built-in function; this example shows how it all works::
Having seen the mechanics behind the iterator protocol, it is easy to add
iterator behavior to your classes. Define an :meth:`__iter__` method which
-returns an object with a :meth:`__next__` method. If the class defines
-:meth:`__next__`, then :meth:`__iter__` can just return ``self``::
+returns an object with a :meth:`~iterator.__next__` method. If the class
+defines :meth:`__next__`, then :meth:`__iter__` can just return ``self``::
class Reverse:
"""Iterator for looping over a sequence backwards."""
@@ -819,8 +819,8 @@ easy to create::
Anything that can be done with generators can also be done with class based
iterators as described in the previous section. What makes generators so
-compact is that the :meth:`__iter__` and :meth:`__next__` methods are created
-automatically.
+compact is that the :meth:`__iter__` and :meth:`~generator.__next__` methods
+are created automatically.
Another key feature is that the local variables and execution state are
automatically saved between calls. This made the function easier to write and