]> granicus.if.org Git - python/commitdiff
Issue 6722: Improve the namedtuple examples.
authorRaymond Hettinger <python@rcn.com>
Sun, 21 Nov 2010 23:23:29 +0000 (23:23 +0000)
committerRaymond Hettinger <python@rcn.com>
Sun, 21 Nov 2010 23:23:29 +0000 (23:23 +0000)
Doc/library/collections.rst

index e34e39479b05346cb1f2c219bc3ec12f473d05c6..3f81c00c20dc3d3e56ebd928b13540a2f42fc650 100644 (file)
@@ -586,11 +586,15 @@ they add the ability to access fields by name instead of position index.
    .. versionchanged:: 3.1
       Added support for *rename*.
 
-Example:
 
 .. doctest::
    :options: +NORMALIZE_WHITESPACE
 
+   >>> # Basic example
+   >>> Point = namedtuple('Point', 'x y')
+   >>> p = Point(x=10, y=11)
+
+   >>> # Example using the verbose option to print the class definition
    >>> Point = namedtuple('Point', 'x y', verbose=True)
    class Point(tuple):
            'Point(x, y)'