Skip to content

Commit aeb9ef4

Browse files
authored
bpo-46076: Improve documentation for per-attribute docstrings with __slots__ (GH-30109)
1 parent 0b582a4 commit aeb9ef4

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

Doc/reference/datamodel.rst

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1944,9 +1944,12 @@ Notes on using *__slots__*
19441944
* Nonempty *__slots__* does not work for classes derived from "variable-length"
19451945
built-in types such as :class:`int`, :class:`bytes` and :class:`tuple`.
19461946

1947-
* Any non-string iterable may be assigned to *__slots__*. Mappings may also be
1948-
used; however, in the future, special meaning may be assigned to the values
1949-
corresponding to each key.
1947+
* Any non-string :term:`iterable` may be assigned to *__slots__*.
1948+
1949+
* If a :class:`dictionary <dict>` is used to assign *__slots__*, the dictionary
1950+
keys will be used as the slot names. The values of the dictionary can be used
1951+
to provide per-attribute docstrings that will be recognised by
1952+
:func:`inspect.getdoc` and displayed in the output of :func:`help`.
19501953

19511954
* :attr:`~instance.__class__` assignment works only if both classes have the
19521955
same *__slots__*.

0 commit comments

Comments
 (0)