Kaydet (Commit) 850be0fb authored tarafından Raymond Hettinger's avatar Raymond Hettinger

Improve namedtuple doc string examples

üst 5e2e7002
...@@ -929,10 +929,10 @@ Docstrings can be customized by making direct assignments to the ``__doc__`` ...@@ -929,10 +929,10 @@ Docstrings can be customized by making direct assignments to the ``__doc__``
fields: fields:
>>> Book = namedtuple('Book', ['id', 'title', 'authors']) >>> 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.id.__doc__ = '13-digit ISBN'
>>> Book.title.__doc__ = 'Title of first printing' >>> 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 Default values can be implemented by using :meth:`_replace` to
customize a prototype instance: customize a prototype instance:
......
...@@ -865,7 +865,7 @@ and improves their substitutability for lists. ...@@ -865,7 +865,7 @@ and improves their substitutability for lists.
Docstrings produced by :func:`~collections.namedtuple` can now be updated:: Docstrings produced by :func:`~collections.namedtuple` can now be updated::
Point = namedtuple('Point', ['x', 'y']) Point = namedtuple('Point', ['x', 'y'])
Point.__doc__ = 'ordered pair' Point.__doc__ += ': Cartesian coodinate'
Point.x.__doc__ = 'abscissa' Point.x.__doc__ = 'abscissa'
Point.y.__doc__ = 'ordinate' Point.y.__doc__ = 'ordinate'
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment