diff options
author | Alex Waygood <Alex.Waygood@Gmail.com> | 2021-12-19 20:20:07 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-12-19 14:20:07 -0600 |
commit | aeb9ef4c7287fe367b6e9adcf1c5f994d5bc1a09 (patch) | |
tree | 2b3d8b3bc3945241cf44d936374f746ef2974a3a /Doc/reference | |
parent | 0b582a4a1b24472a35ed7fc973728ac9d595f123 (diff) | |
download | cpython-git-aeb9ef4c7287fe367b6e9adcf1c5f994d5bc1a09.tar.gz |
bpo-46076: Improve documentation for per-attribute docstrings with `__slots__` (GH-30109)
Diffstat (limited to 'Doc/reference')
-rw-r--r-- | Doc/reference/datamodel.rst | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/Doc/reference/datamodel.rst b/Doc/reference/datamodel.rst index aa0d91ad1c..48c54d7294 100644 --- a/Doc/reference/datamodel.rst +++ b/Doc/reference/datamodel.rst @@ -1944,9 +1944,12 @@ Notes on using *__slots__* * Nonempty *__slots__* does not work for classes derived from "variable-length" built-in types such as :class:`int`, :class:`bytes` and :class:`tuple`. -* Any non-string iterable may be assigned to *__slots__*. Mappings may also be - used; however, in the future, special meaning may be assigned to the values - corresponding to each key. +* Any non-string :term:`iterable` may be assigned to *__slots__*. + +* If a :class:`dictionary <dict>` is used to assign *__slots__*, the dictionary + keys will be used as the slot names. The values of the dictionary can be used + to provide per-attribute docstrings that will be recognised by + :func:`inspect.getdoc` and displayed in the output of :func:`help`. * :attr:`~instance.__class__` assignment works only if both classes have the same *__slots__*. |