This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Build-out help() to support a class level data dictionary
Type: Stage: resolved
Components: Library (Lib) Versions: Python 3.8
process
Status: closed Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: rhettinger
Priority: normal Keywords:

Created on 2019-03-17 09:28 by rhettinger, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Messages (3)
msg338121 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2019-03-17 09:28
class Bicycle:

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

>>> help(Bicycle)
class Bicycle(builtins.object)
 |  Data fields defined here:
 |
 |  category
 |      Primary use: road, cross-over, or hybrid
 |
 |  model
 |      Unique six digit vendor-supplied code
 |
 |  size
 |      Rider size: child, small, medium, large, extra-large
 |
 |  price
 |      Manufacturer suggested retail price
 |
 |  ----------------------------------------------------------------------
 |
 |  Data descriptors defined here:
 |  
 |  __dict__
 |      dictionary for instance variables (if defined)
 |  
 |  __weakref__
 |      list of weak references to the object (if defined)
 |  
 |  ----------------------------------------------------------------------
 |  Data and other attributes defined here:
 |  
 |  __data_dictionary__ = {'category': 'Primary use: road, cross-over, or .
msg338122 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2019-03-17 09:51
Something like this would be especially helpful for classes using __slots__. 

The member objects show-up in help(), but there is no way to attach an explanation like we can with property objects.

So there is a slots only alternative that would only involve modifying help() and nothing else:

   class Bicycle:

       __slots__ = dict(
           category = 'Primary use: road, cross-over, or hybrid',
           model = 'Unique six digit vendor-supplied code',
           size = 'Rider size: child, small, medium, large, extra-large',
           price = 'Manufacturer suggested retail price', 
       )
msg338123 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2019-03-17 09:52
Moving to a fresh issue.
History
Date User Action Args
2022-04-11 14:59:12adminsetgithub: 80506
2019-03-17 09:52:49rhettingersetstatus: open -> closed

messages: + msg338123
stage: resolved
2019-03-17 09:51:00rhettingersetmessages: + msg338122
2019-03-17 09:28:43rhettingercreate