[issue36326] Build-out help() to read __slots__ with an optional data dictionary

Serhiy Storchaka report at bugs.python.org
Sun Mar 17 08:50:22 EDT 2019


Serhiy Storchaka <storchaka+cpython at gmail.com> added the comment:

I am not sure that this is the best application of dict as __slots__. Maybe use dict for specifying default values? Currently slots are not compatible with class-level values used as fallbacks.

Following the pattern for namedtuple attributes, docstrings for slots could be specified as:

class Bicycle:
       __slots__ = 'category', 'model', 'size', 'price'

Bicycle.category.__doc__ = 'Primary use: road, cross-over, or hybrid'
Bicycle.model.__doc__ = 'Unique six digit vendor-supplied code'
Bicycle.size.__doc__ = 'Rider size: child, small, medium, large, extra-large'
Bicycle.price.__doc__ = 'Manufacturer suggested retail price'

----------
nosy: +serhiy.storchaka

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


More information about the Python-bugs-list mailing list