Skip to content

Commit

Permalink
bpo-46076: Improve documentation for per-attribute docstrings with `_…
Browse files Browse the repository at this point in the history
  • Loading branch information
miss-islington committed Dec 19, 2021
1 parent 2352644 commit 8bfb11a
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions Doc/reference/datamodel.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1868,9 +1868,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__*.
Expand Down

0 comments on commit 8bfb11a

Please sign in to comment.