summaryrefslogtreecommitdiffstats
path: root/Doc/reference
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2021-12-19 21:11:12 (GMT)
committerGitHub <noreply@github.com>2021-12-19 21:11:12 (GMT)
commitd7537ac8e3a3ef15d2c5f3fe90e998618b6a97b9 (patch)
tree3fe18b60ab59b0dd3a463b5125b8a5cb0b829b11 /Doc/reference
parentcdb4579607ad5e0a3978ec29b8407bea4d19b4fa (diff)
downloadcpython-d7537ac8e3a3ef15d2c5f3fe90e998618b6a97b9.zip
cpython-d7537ac8e3a3ef15d2c5f3fe90e998618b6a97b9.tar.gz
cpython-d7537ac8e3a3ef15d2c5f3fe90e998618b6a97b9.tar.bz2
bpo-46076: Improve documentation for per-attribute docstrings with `__slots__` (GH-30109) (GH-30206)
Diffstat (limited to 'Doc/reference')
-rw-r--r--Doc/reference/datamodel.rst9
1 files changed, 6 insertions, 3 deletions
diff --git a/Doc/reference/datamodel.rst b/Doc/reference/datamodel.rst
index d2e586a..be1f714 100644
--- a/Doc/reference/datamodel.rst
+++ b/Doc/reference/datamodel.rst
@@ -1877,9 +1877,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__*.