]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-46076: Improve documentation for per-attribute docstrings with `__slots__` (GH...
authorAlex Waygood <Alex.Waygood@Gmail.com>
Sun, 19 Dec 2021 20:20:07 +0000 (20:20 +0000)
committerGitHub <noreply@github.com>
Sun, 19 Dec 2021 20:20:07 +0000 (14:20 -0600)
Doc/reference/datamodel.rst

index aa0d91ad1c97d2904baf2ebe54bc5c3612bea0e7..48c54d729424c73b50cc4a439d1b5735b22405c2 100644 (file)
@@ -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__*.