Author rhettinger
Recipients rhettinger
Date 2019-03-17.10:11:15
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1552817476.02.0.169886885887.issue36326@roundup.psfhosted.org>
In-reply-to
Content
The __slots__ variable already works with dictionaries.  The values are simply ignored. 

I propose teaching help() to read those optional dictionaries to give better information on member objects (much like we already have with property objects).

This is inspired by data dictionaries for database tables.

The pydoc implementation would be somewhat easy.  Roughly this:

   for name in data_descriptors:
       print(f' |  {name}'
       if isinstance(slots, dict) and name in slots:
           print(f' |      {slots[name]}')
       print(' |')


==== Example ====================================================

>>> 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', 
       )

>>> help(Bicycle)
Help on class Bicycle in module __main__:

class Bicycle(builtins.object)
 |  Data descriptors defined here:
 |  
 |  category
 |      Primary use: road, cross-over, or hybrid
 |  
 |  model
 |      Unique six digit vendor-supplied code
 |  
 |  price
 |      Rider size: child, small, medium, large, extra-large
 |  
 |  size
 |      Manufacturer suggested retail price
History
Date User Action Args
2019-03-17 10:11:16rhettingersetrecipients: + rhettinger
2019-03-17 10:11:16rhettingersetmessageid: <1552817476.02.0.169886885887.issue36326@roundup.psfhosted.org>
2019-03-17 10:11:16rhettingerlinkissue36326 messages
2019-03-17 10:11:15rhettingercreate