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.

Author LewisGaul
Recipients LewisGaul, eric.smith, eric.snow, rhettinger, serhiy.storchaka
Date 2021-01-31.12:52:46
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1612097566.96.0.141121093848.issue43080@roundup.psfhosted.org>
In-reply-to
Content
> a dataclass can do anything a regular class can do

Agreed, but isn't that also true of any subclasses of currently supported types? In particular 'UserDict', 'UserList' and 'UserString', which all have explicit support in pprint and are intended for "easier subclassing" according to the docs.

I'm also not sure why it would be a reason for not giving it pprint handling (in the case where there's no user-defined __repr__). Is there any harm in doing so? 

I'd consider dataclasses one of the primary choices for storing data in modern Python (e.g. for converting to/from JSON/YAML), and may well be used for storing nested data, which can be very hard to read without some mechanism for pretty-printing.

Indeed, the dataclasses.asdict() function recurses into dataclass fields. This gives the option of pprint(dataclasses.asdict(my_dataclass)), but at the cost of losing the class names and any custom reprs.
History
Date User Action Args
2021-01-31 12:52:46LewisGaulsetrecipients: + LewisGaul, rhettinger, eric.smith, eric.snow, serhiy.storchaka
2021-01-31 12:52:46LewisGaulsetmessageid: <1612097566.96.0.141121093848.issue43080@roundup.psfhosted.org>
2021-01-31 12:52:46LewisGaullinkissue43080 messages
2021-01-31 12:52:46LewisGaulcreate