[Python-Dev] Re: What to do about invalid escape sequences

2019年8月10日 04:33:31 -0700

On 06/08/2019 23:41:25, Greg Ewing wrote:
Rob Cliffe via Python-Dev wrote:
Sorry, that won't work. Strings are parsed at compile time, open() is executed at run-time.
It could check for control characters, which are probably the result
of a backslash accident. Maybe even auto-correct them...
By "It", do you mean open() ? If so:
It already checks for control characters, at least with Python 2.7 on Windows:
>>> open('mydir\test')
Traceback (most recent call last):
 File "<stdin>", line 1, in <module>
IOError: [Errno 22] invalid mode ('r') or filename: 'mydir\test'
As for auto-correct (presumably "\a" to "\\a", "\b" to "\\b" etc.), I hope you're not serious. "In the face of gibberish, refuse the temptation to show how smart your guessing is."
_______________________________________________
Python-Dev mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at 
https://mail.python.org/archives/list/[email protected]/message/UK46EASIZVFTIQPORH7AG3EFB522NFI3/

Reply via email to