Mailing List Archive

Improving readability of interpreter expression output (was The purpose of 'repr'...)
Hi!

Tim Peters:
[...]
> This is a different issue than (but related to) what the interactive prompt
> should use by default to format expression results. They have one key
> conundrum in common, though: if str() is simply passed down with no other
> change, then e.g.
>
> print str({"a:": "b, c", "a, b": "c"})
> and (same thing in disguise)
> print {"a:": "b, c", "a, b": "c"}
>
> would display
>
> {a:: b, c, a, b: c}
>
> and that's darned unreadable.

Would you please elaborate a bit more, what you have in mind with
"other change" in your sentence above?

> As far as I can tell, the only reason
> str(container) invokes repr on the containees today is simply to get some
> string quotes in output like this. That's fine so far as it goes, but leads
> to miserably bloated displays for containees of many types *other* than the
> builtin ones -- and even for string containees leads to embedded octal
> escape sequences all over the place.
>
> > I don't know how to fix this, though. :-(
>
> Sure you do! And we look forward to your patch <wink>.

No. Serious. I don't see how to fix the 'darned unreadable' output.
passing 'str' down seems to be simple. But how to fix the problem
above isn't obvious to me.

Regards, Peter