diff options
author | Raymond Hettinger <rhettinger@users.noreply.github.com> | 2019-03-25 20:01:13 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-03-25 20:01:13 (GMT) |
commit | d1e768a67707bf7bb426c1537e1a764e89eaff78 (patch) | |
tree | eba1dc9c8a257e8c9fec36cef006eb06498d54ee /Doc | |
parent | 713a8ae7926472b02ee1a394633eb54aaa7912d1 (diff) | |
download | cpython-d1e768a67707bf7bb426c1537e1a764e89eaff78.zip cpython-d1e768a67707bf7bb426c1537e1a764e89eaff78.tar.gz cpython-d1e768a67707bf7bb426c1537e1a764e89eaff78.tar.bz2 |
bpo-36326: Let inspect.getdoc() find docstrings for __slots__ (GH-12498)
Diffstat (limited to 'Doc')
-rw-r--r-- | Doc/whatsnew/3.8.rst | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/Doc/whatsnew/3.8.rst b/Doc/whatsnew/3.8.rst index 3855d36..6ab7991 100644 --- a/Doc/whatsnew/3.8.rst +++ b/Doc/whatsnew/3.8.rst @@ -174,6 +174,20 @@ gettext Added :func:`~gettext.pgettext` and its variants. (Contributed by Franz Glasner, Éric Araujo, and Cheryl Sabella in :issue:`2504`.) +inspect +------- + +The :func:`inspect.getdoc` function can now find docstrings for ``__slots__`` +if that attribute is a :class:`dict` where the values are docstrings. +This provides documentation options similar to what we already have +for :func:`property`, :func:`classmethod`, and :func:`staticmethod`:: + + class AudioClip: + __slots__ = {'bit_rate': 'expressed in kilohertz to one decimal place', + 'duration': 'in seconds, rounded up to an integer'} + def __init__(self, bit_rate, duration): + self.bit_rate = round(bit_rate / 1000.0, 1) + self.duration = ceil(duration) gc -- |