[Python-Dev] Emit SyntaxWarning on unrecognized backslash escapes?

Guido van Rossum guido at python.org
Tue Feb 24 19:49:56 CET 2015


I like the \x07 solution.

On Tue, Feb 24, 2015 at 10:47 AM, Ethan Furman <ethan at stoneleaf.us> wrote:

> On 02/24/2015 10:14 AM, Guido van Rossum wrote:
>
> > This is about messages from failing file-open operations if the filename
> contains an escaped character? I'd go slow
> > there too: here are a lot of places where files are opened and messages
> are printed, both in the C code and in the
> > stdlib. I'm not sure I buy the argument that just echoing the repr() of
> the name back doesn't help -- the escapes in
> > there are actually useful in case a filename containing garbage chars
> (or even a trailing space) was read from some
> > other source.
>
> I can attest from my impoverished Windows programming days that looking at
>
>   --> os.listdir('c:\temp')
>   SomeErrorMessage about syntax 'c:\temp'
>
> is not very helpful.  There is zero visual indication that the \ and the t
> are one character, not two.  Changing that
> error message to:
>
>   SomeErrorMessage about syntax 'c:[\t]emp'
>
> or
>
>   SomeErrorMessage about syntax 'c:\x07emp'
>
> or something that shouts out, "hey!  one character in this location!"
> would be a good thing.
>
> --
> ~Ethan~
>
>
> _______________________________________________
> Python-Dev mailing list
> Python-Dev at python.org
> https://mail.python.org/mailman/listinfo/python-dev
> Unsubscribe:
> https://mail.python.org/mailman/options/python-dev/guido%40python.org
>
>


-- 
--Guido van Rossum (python.org/~guido)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-dev/attachments/20150224/03678f28/attachment.html>


More information about the Python-Dev mailing list