diff options
author | Raymond Hettinger <python@rcn.com> | 2015-05-13 08:09:59 (GMT) |
---|---|---|
committer | Raymond Hettinger <python@rcn.com> | 2015-05-13 08:09:59 (GMT) |
commit | eac503aeac6fedc81001b9e1136957d45b9a2c51 (patch) | |
tree | 9b39bdd76843421487a78e56b2eb50c548e47d04 /Doc | |
parent | f2244eaf9e3148d6270839e9aa7c2ad9752c17ed (diff) | |
download | cpython-eac503aeac6fedc81001b9e1136957d45b9a2c51.zip cpython-eac503aeac6fedc81001b9e1136957d45b9a2c51.tar.gz cpython-eac503aeac6fedc81001b9e1136957d45b9a2c51.tar.bz2 |
Issue #24064: Property() docstrings are now writeable.
(Patch by Berker Peksag.)
Diffstat (limited to 'Doc')
-rw-r--r-- | Doc/library/collections.rst | 9 | ||||
-rw-r--r-- | Doc/whatsnew/3.5.rst | 16 |
2 files changed, 25 insertions, 0 deletions
diff --git a/Doc/library/collections.rst b/Doc/library/collections.rst index dd6395d..892f05d 100644 --- a/Doc/library/collections.rst +++ b/Doc/library/collections.rst @@ -924,6 +924,15 @@ create a new named tuple type from the :attr:`_fields` attribute: >>> Point3D = namedtuple('Point3D', Point._fields + ('z',)) +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.id = '13-digit ISBN' + >>> Book.title = 'Title of first printing' + >>> Book.author = 'List of authors sorted by last name' + Default values can be implemented by using :meth:`_replace` to customize a prototype instance: diff --git a/Doc/whatsnew/3.5.rst b/Doc/whatsnew/3.5.rst index 48d871a..a29ff10 100644 --- a/Doc/whatsnew/3.5.rst +++ b/Doc/whatsnew/3.5.rst @@ -234,6 +234,10 @@ Some smaller changes made to the core Python language are: * New Kazakh :ref:`codec <standard-encodings>` ``kz1048``. (Contributed by Serhiy Storchaka in :issue:`22682`.) +* Property docstrings are now writable. This is especially useful for + :func:`collections.namedtuple` docstrings. + (Contributed by Berker Peksag in :issue:`24064`.) + * New Tajik :ref:`codec <standard-encodings>` ``koi8_t``. (Contributed by Serhiy Storchaka in :issue:`22681`.) @@ -283,6 +287,18 @@ code the full chained traceback, just like the interactive interpreter. (Contributed by Claudiu Popa in :issue:`17442`.) +collections +----------- + +* You can now update docstrings produced by :func:`collections.namedtuple`:: + + Point = namedtuple('Point', ['x', 'y']) + Point.__doc__ = 'ordered pair' + Point.x.__doc__ = 'abscissa' + Point.y.__doc__ = 'ordinate' + + (Contributed by Berker Peksag in :issue:`24064`.) + compileall ---------- |