[Python-Dev] repr vs. str and locales again

Greg Ward gward@mems-exchange.org
Fri, 19 May 2000 08:45:12 -0400

On 19 May 2000, Guido van Rossum said:
> The email below suggests a simple solution to a problem that
> e.g. Fran\347ois Pinard brought up long ago; repr() of a string turns
> all non-ASCII chars into \oct escapes.  Jyrki's solution: use
> isprint(), which makes it locale-dependent.  I can live with this.

For "ASCII" strings in this day and age -- which are often not
necessarily plain ol' 7-bit ASCII -- I'd say that "32 <= c <= 127" is
not the right way to determine printability.  'isprint()' seems much
more appropriate to me.

Are there other areas of Python that should be locale-sensitive but
aren't?  A minor objection to this patch is that it's a creeping change
that brings in a little bit of locale-sensitivity without addressing a
(possibly) wider problem.  However, I will immediately shoot down my own
objection on the grounds that if we try to fix everything all at once,
then nothing will ever get fixed.  Locale sensitivity strikes me as the
sort of thing that *can* be a "creeping" change -- just fix the bits
that bug people most, and eventually all the important bits will be

I have no expertise and therefore no opinion on such a change for
Unicode strings.