[New-bugs-announce] [issue46076] Document using __slots__ to provide per-attribute docstrings

Alex Waygood report at bugs.python.org
Tue Dec 14 17:25:11 EST 2021


New submission from Alex Waygood <Alex.Waygood at Gmail.com>:

The ability to add docstrings for individual attributes, by using a dictionary for __slots__ was added in Issue36326. This is a fantastic feature, and deserves better documentation. It appears to currently only be documented in the "What's New" entry for Python 3.8: https://docs.python.org/3/whatsnew/3.8.html#inspect.

Moreover, the data model documentation currently states the following regarding using a mapping to specify __slots__:

"""
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.
"""

This is arguably now incorrect. A special meaning has been assigned to the values corresponding to each key: the values can be used for per-attribute docstrings.

----------
assignee: docs at python
components: Documentation
messages: 408573
nosy: AlexWaygood, docs at python, rhettinger
priority: normal
severity: normal
status: open
title: Document using __slots__ to provide per-attribute docstrings
type: enhancement
versions: Python 3.10, Python 3.11, Python 3.9

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue46076>
_______________________________________


More information about the New-bugs-announce mailing list