[Python-3000] Recursive str
Paul Moore
p.f.moore at gmail.com
Wed Apr 16 00:53:14 CEST 2008
On 15/04/2008, Terry Reedy <tjreedy at udel.edu> wrote:
> "Guido van Rossum" <guido at python.org> wrote in message
> | So it sounds like we're doomed if we do, and damned if we don't. Or do
> | I misunderstand you? Do you have a practical suggestion?
>
> You understood the same as me.
That's how it sounded to me, as well.
> I suspect the real solution has to be language-community (and even
> programmer) specific, since I expect most people would like the chars they
> know and expect to be unescaped and others left escaped. So, perhaps there
> should be a unirep module, stdlib or not, used like:
>
> import unirep
> print(*map(unirep.russian, objects))
>
> or even
>
> from unirep import rus_print
>
> rus_print(ojbects) # does same as above, with **kwds passed on
To put this another way, repr() has a single advantage, that it's as
near as possible unambiguous while using only ASCII (the "only ASCII"
bit is to avoid ambiguity between identical-looking glyphs).
Readability is explicitly *not* a goal in this context.
If you want a readable version, write it yourself (or import someone
else's - possibly the stdlib's if anyone writes one). If you don't
want to change your code, write
from my_repr import my_repr as repr
or fiddle with builtins if you want to do this across all modules.
So repr() should stay as it is, and it should be remembered that it is
*not* intended for reading, but for debugging. Stephen's point that
some errors are more easily debuggable with a readable version is, in
my English-only view (:-)), a corner case, although I'm happy to
concede, a valid one.
Paul.
More information about the Python-3000
mailing list