On 02/24/2015 02:58 AM, Chris Angelico wrote: > On Tue, Feb 24, 2015 at 7:40 PM, M.-A. Lemburg <mal at egenix.com> wrote: >> I think the easiest way would be to tweak the error message >> output to indicate the real problem. >> >> At the moment, you get: >> >>>>> open('c:\test.txt') >> Traceback (most recent call last): >> File "<stdin>", line 1, in <module> >> FileNotFoundError: [Errno 2] No such file or directory: 'c:\test.txt' >> >> which isn't helpful. > > The problem isn't the cases where the file can't be found. Those can > be dealt with fairly easily, one way or another. The problem is much, > much earlier, when the student was using "c:\sample.txt" and > everything was working fine. Then he changed the code over to use his > own file instead of the provided sample, and at the same time, > switched from using open() to using csv.reader(open()), and moved all > the code into a function, and fixed three other bugs, and now it isn't > working. And he can't figure out why. > > That's why I'd like "c:\sample.txt" to raise a warning. > > Should I start writing up a PEP? Is that the way forward with this? Go for it. I think the solution will be two pieces: - deprecating unknown backslash-escapes, with the goal of eventually being a SyntaxError (this removes a wart from the language, as well as allowing a warning backport to 2.7) - M.A.Lemburg's idea of changing the exception message in key places to make a successful backslash replace obvious (FileNotFoundError: [Errno 2] No such file or directory: 'c:[\t]est.txt' - warning: embedded escapes) -- ~Ethan~ -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 836 bytes Desc: OpenPGP digital signature URL: <http://mail.python.org/pipermail/python-dev/attachments/20150224/57d80a06/attachment.sig>
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4