Formalized pretty & encoding-aware object representation (was dunder methods for...)

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>
Alex Hall wrote:
Might be helpful to look at https://github.com/tommikaikkonen/prettyprinter and https://github.com/wolever/pprintpp

Oops. Somehow this subject was posted twice. Please ignore this thread & follow the other thread with the same subject line.

Oops. Somehow this subject was posted twice. Please ignore this thread & follow the other thread with the same subject line.
participants (1)
-
Steve Jorgensen