Issue36325
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) * ![]() |
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) * ![]() |
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) * ![]() |
Date: 2019-03-17 09:52 | |
Moving to a fresh issue. |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022-04-11 14:59:12 | admin | set | github: 80506 |
| 2019-03-17 09:52:49 | rhettinger | set | status: open -> closed messages:
+ msg338123 |
| 2019-03-17 09:51:00 | rhettinger | set | messages: + msg338122 |
| 2019-03-17 09:28:43 | rhettinger | create | |
