Based on the conversations stemming from my previous post, it is clear that the 
topic was too implementation-specific. It is not clear whether dunder methods 
are an appropriate component of the solution (they might or might not be).

This suggestion is to try to solve 2 inter-related but different issues, 
possibly through the same mechanism, 2 unrelated mechanisms, or partially 
overlapping mechanisms.

Although the current `__str__` and `__repr__` concepts seem perfectly 
appropriate to me, I think there also is justification for a means of having 
standard pretty-informal (str-like) and pretty-formal (repr-like) 
representations for various types of object.  In the informal case, it should 
be possible to pass information about a file object that it will be written to 
(especially encoding & possibly isatty()) to the representation code, and in 
the formal case, either the representation code should interact with the 
pretty-printer or it should be able to return data in a from that tells the 
pretty printer how to nest portions of the representation.

It presumably makes sense to start by looking at prior art rather than 
inventing from scratch.

Quotes from previous thread regarding prior art to look at:

Jonathan Fine wrote:
<snip>
> Here's some comments on the state of the art. In addition to
> https://docs.python.org/3/library/pprint.html
> there's also
> https://docs.python.org/3/library/reprlib.html
> and
> https://docs.python.org/3/library/json.html
> I expect that these three modules have some overlap in purpose and design
> (but probably not in code).
> And if you're brave, there's also
> https://docs.python.org/3/library/pickle.html
> and
> https://github.com/psf/black
> Time to declare a special interest. I'm a long-time user and great fan of
> TeX / LaTeX. And some nice way of pretty-printing Python objects using TeX
> notation could be useful.
> And also related is Geoffrey French's Larch environment for editing Python,
> which has a pretty-printing component.
> http://www.britefury.com/larch_site/
> with best wishes
> Jonathan

Alex Hall wrote:
> Might be helpful to look at https://github.com/tommikaikkonen/prettyprinter
>  and https://github.com/wolever/pprintpp
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/GLXVPG6UAOTEKDVCV362CTGB4EGYYWPP/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to