Improve namedtuple doc string examples
authorRaymond Hettinger <python@rcn.com>
Mon, 9 Nov 2015 16:24:53 +0000 (08:24 -0800)
committerRaymond Hettinger <python@rcn.com>
Mon, 9 Nov 2015 16:24:53 +0000 (08:24 -0800)
Doc/library/collections.rst
Doc/whatsnew/3.5.rst

index 0e5ff200085fec426add3c4f74975f03a5639c62..8ab757194a633307c4e47eadd1b38392211eff1b 100644 (file)
@@ -929,10 +929,10 @@ Docstrings can be customized by making direct assignments to the ``__doc__``
 fields:
 
    >>> Book = namedtuple('Book', ['id', 'title', 'authors'])
-   >>> Book.__doc__ = 'Hardcover book in active collection'
+   >>> Book.__doc__ += ': Hardcover book in active collection'
    >>> Book.id.__doc__ = '13-digit ISBN'
    >>> Book.title.__doc__ = 'Title of first printing'
-   >>> Book.author.__doc__ = 'List of authors sorted by last name'
+   >>> Book.authors.__doc__ = 'List of authors sorted by last name'
 
 Default values can be implemented by using :meth:`_replace` to
 customize a prototype instance:
index 29d76b111289e33b2ead1a6390e06f82f4f52c07..f3db22fa7614b38f2e18cfbf8ab0021244f1d9e9 100644 (file)
@@ -865,7 +865,7 @@ and improves their substitutability for lists.
 Docstrings produced by :func:`~collections.namedtuple` can now be updated::
 
     Point = namedtuple('Point', ['x', 'y'])
-    Point.__doc__ = 'ordered pair'
+    Point.__doc__ += ': Cartesian coodinate'
     Point.x.__doc__ = 'abscissa'
     Point.y.__doc__ = 'ordinate'