]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Split combined code/doctest code blocks in two blocks, to enable proper highlighting.
authorGeorg Brandl <georg@python.org>
Sun, 1 May 2011 20:36:31 +0000 (22:36 +0200)
committerGeorg Brandl <georg@python.org>
Sun, 1 May 2011 20:36:31 +0000 (22:36 +0200)
Doc/tutorial/classes.rst

index ed0e6557c20d8283d0a3f60f5ae77ff83f8e5234..5ee9067784625deaa50268dc45aaa5e0853d684f 100644 (file)
@@ -687,7 +687,6 @@ This example shows how it all works::
    >>> it.next()
    'c'
    >>> it.next()
-
    Traceback (most recent call last):
      File "<stdin>", line 1, in ?
        it.next()
@@ -699,7 +698,7 @@ returns an object with a :meth:`next` method.  If the class defines
 :meth:`next`, then :meth:`__iter__` can just return ``self``::
 
    class Reverse:
-       "Iterator for looping over a sequence backwards"
+       """Iterator for looping over a sequence backwards."""
        def __init__(self, data):
            self.data = data
            self.index = len(data)
@@ -711,6 +710,8 @@ returns an object with a :meth:`next` method.  If the class defines
            self.index = self.index - 1
            return self.data[self.index]
 
+::
+
    >>> rev = Reverse('spam')
    >>> iter(rev)
    <__main__.Reverse object at 0x00A1DB50>
@@ -739,6 +740,8 @@ easy to create::
        for index in range(len(data)-1, -1, -1):
            yield data[index]
 
+::
+
    >>> for char in reverse('golf'):
    ...     print char
    ...