[Python-ideas] __repr__: to support pprint

Chris Angelico rosuav at gmail.com
Tue Feb 28 21:04:00 EST 2017


On Wed, Mar 1, 2017 at 12:58 PM, Matthias welp <boekewurm at gmail.com> wrote:
> You are free to experiment with overriding/extending __repr__ for your
> internal usage, but please note that it might break external libraries
> depending on obj.__repr__ or repr(obj), and print() might break when
> using built-in types as containers for your objects.

Given that this started out with a post about pprint, maybe a more
viable approach would be a dedicated __pprint__ hook? That might be
easier to push through. (I'm not pushing for it though.)

ChrisA


More information about the Python-ideas mailing list