Re: [Python-Dev] Emit SyntaxWarning on unrecognized backslash escapes?
[Adding back python-dev] Actually, I wasn't proposing to change repr() -- my sentiments are similar to Isaac Morland's. Only the error message for the most basic file open() call should be tweaked. No solution is perfect -- but it's probably common enough for someone to create a file or folder named C:\test and being stumped by "cannot open 'C:\test'." On Tue, Feb 24, 2015 at 1:25 PM, Glenn Linderman <v+python@g.nevcal.com> wrote:
On 2/24/2015 10:49 AM, Guido van Rossum wrote:
I like the \x07 solution.
The more I think about it, the more I think this is a sufficient solution. People that use repr to get a Python-compatible string syntax for further program use get one. People that see them in an error message are much less likely to be fooled into thinking it is two characters, because they are thinking of it as two characters to start with.
On the other hand, I have a directory full of "throw away" experimental source files named x01, x02, x03, ... :)
And I suppose extensive use of certain characters in repr in intermediate or archived data could make such data grow in size.
And while \t and \n are very commonly used escapes, maybe string repr could have a special function called .I_promise_not_to_report_issues_when_I_use_backslash_escapes_in_character_literals_and_get_confused() which would switch back from \x07 to \t and \x0a to \n, etc. This would be callable only from __main__ :)
-- --Guido van Rossum (python.org/~guido)
On 02/24/2015 01:35 PM, Guido van Rossum wrote:
Actually, I wasn't proposing to change repr() -- my sentiments are similar to Isaac Morland's. Only the error message for the most basic file open() call should be tweaked.
As are mine -- I just like to be thorough when discussing possibilities. -- ~Ethan~
participants (2)
-
Ethan Furman
-
Guido van Rossum