Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #86202 > unrolled thread

Re: Unrecognized backslash escapes in string literals

Started byPeter Otten <__peter__@web.de>
First post2015-02-23 09:41 +0100
Last post2015-02-23 09:41 +0100
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: Unrecognized backslash escapes in string literals Peter Otten <__peter__@web.de> - 2015-02-23 09:41 +0100

#86202 — Re: Unrecognized backslash escapes in string literals

FromPeter Otten <__peter__@web.de>
Date2015-02-23 09:41 +0100
SubjectRe: Unrecognized backslash escapes in string literals
Message-ID<mailman.19059.1424680918.18130.python-list@python.org>
Ben Finney wrote:

> Chris Angelico <rosuav@gmail.com> 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 appropriate place to
> implement them would be in PyLint or another established static code
> analysis tool.

Pylint already produces a warning. However, it cannot read the author's 
mind:

$ cat tmp.py
print("C:\alpha")
print("C:\beta")
print("C:\gamma")
$ pylint tmp.py
************* Module tmp
W:  3, 0: Anomalous backslash in string: '\g'. String constant might be 
missing an r prefix. (anomalous-backslash-in-string)
C:  1, 0: Missing module docstring (missing-docstring)

The same would go for a warning built into the compiler. Maybe having 
editors highlight the special combinations would be the more helpful 
approach. A tooltip could explain the meaning.



[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web