Message354154
Dataclasses provide a very straightforward way to specify structured data. One can trivally document a dataclass's attributes via triple-quoted attribute docstrings per PEP 257. However, those docstrings are not accessible to pydoc, so they are lost to users of the dataclass.
For example, the attribute docstrings in the below dataclass should be available when looking at `help(SpectralData)`, but that help command does not show the docstrings.
```
@dataclasses.dataclass
class SpectralData:
"""Class to hold data and metadata from a fiber spectrograph."""
wavelength: astropy.units.Quantity
"""The wavelength array produced by the instrument."""
spectrum: np.ndarray
"""The flux array in instrumental units."""
duration: float
"""The duration of the exposure in seconds."""
``` |
|
Date |
User |
Action |
Args |
2019-10-08 00:24:53 | John Parejko2 | set | recipients:
+ John Parejko2, docs@python |
2019-10-08 00:24:53 | John Parejko2 | set | messageid: <1570494293.05.0.934356434949.issue38401@roundup.psfhosted.org> |
2019-10-08 00:24:52 | John Parejko2 | link | issue38401 messages |
2019-10-08 00:24:52 | John Parejko2 | create | |
|