10 Aug
2019
10 Aug
'19
11:29 a.m.
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."