[issue43080] pprint for dataclass instances

Raymond Hettinger report at bugs.python.org
Sun Jan 31 13:15:07 EST 2021


Raymond Hettinger <raymond.hettinger at gmail.com> added the comment:

At some point, we need a modern redesign alternative to pprint.  It could have its own __pprint__ method to communicate how it wants to be pretty printed.

Until then, I think the existing pprint module should only grow custom support for classes that have a mostly consistent structure and usage pattern.  SimpleNamespace, for example, made sense for a custom pprint handler because it is so dict like and is almost never customized.

IMO, dataclasses are a bridge too far.  Having pprint() guess what a dataclass intends is not far from try to guess what an arbitrary class intends.  This is skating on thin ice.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue43080>
_______________________________________


More information about the Python-bugs-list mailing list