Re: Unrecognized backslash escapes in string literals

2015-02-23 Thread Serhiy Storchaka
On 23.02.15 04:55, Chris Angelico wrote: I agree, the fault is primarily with Windows. But I've seen similar issues when people use /-\| for box drawing and framing and such; Windows paths are by far the most common case of this, but not the sole. There is also issues with regular expressions.

Re: Unrecognized backslash escapes in string literals

2015-02-23 Thread Peter Otten
Ben Finney wrote: > Chris Angelico writes: > >> That said, though, there's probably a lot of code out there that >> depends on backslashes being non-special, so it's quite probably >> something that can't be changed. But it'd be nice to be able to turn >> on a warning for it. > > If you're moti

Re: Unrecognized backslash escapes in string literals

2015-02-22 Thread Ben Finney
Chris Angelico writes: > That said, though, there's probably a lot of code out there that > depends on backslashes being non-special, so it's quite probably > something that can't be changed. But it'd be nice to be able to turn > on a warning for it. If you're motivated to see such warnings, an

Re: Unrecognized backslash escapes in string literals

2015-02-22 Thread Chris Angelico
On Mon, Feb 23, 2015 at 1:41 PM, Ben Finney wrote: > Right. Text strings literals are documented to work that way > https://docs.python.org/3/library/stdtypes.html#text-sequence-type-str>, > which refers the reader to the language reference > https://docs.python.org/3/reference/lexical_analysis.ht

Re: Unrecognized backslash escapes in string literals

2015-02-22 Thread Dave Angel
On 02/22/2015 09:41 PM, Ben Finney wrote: Chris Angelico writes: In Python, unrecognized escape sequences are treated literally, without (as far as I can tell) any sort of warning or anything. Right. Text strings literals are documented to work that way https://docs.python.org/3/library/stdt

Re: Unrecognized backslash escapes in string literals

2015-02-22 Thread Chris Angelico
On Mon, Feb 23, 2015 at 1:41 PM, Ben Finney wrote: > Chris Angelico writes: > >> Why is it that Python interprets them this way, and doesn't even give >> a warning? > > Because the interpretation of those literals is unambiguous and correct. And it also implies that never, in the entire infinite

Re: Unrecognized backslash escapes in string literals

2015-02-22 Thread Dave Angel
On 02/22/2015 09:29 PM, Chris Angelico wrote: In Python, unrecognized escape sequences are treated literally, without (as far as I can tell) any sort of warning or anything. This can mask bugs, especially when Windows path names are used: 'C:\sqlite\Beginner.db' 'C:\\sqlite\\Beginner.db' 'c:\

Re: Unrecognized backslash escapes in string literals

2015-02-22 Thread Ben Finney
Chris Angelico writes: > In Python, unrecognized escape sequences are treated literally, > without (as far as I can tell) any sort of warning or anything. Right. Text strings literals are documented to work that way https://docs.python.org/3/library/stdtypes.html#text-sequence-type-str>, which r

Unrecognized backslash escapes in string literals

2015-02-22 Thread Chris Angelico
In Python, unrecognized escape sequences are treated literally, without (as far as I can tell) any sort of warning or anything. This can mask bugs, especially when Windows path names are used: >>> 'C:\sqlite\Beginner.db' 'C:\\sqlite\\Beginner.db' >>> 'c:\sqlite\beginner.db' 'c:\\sqlite\x08eginner.