Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #86202
| From | Peter Otten <__peter__@web.de> |
|---|---|
| Subject | Re: Unrecognized backslash escapes in string literals |
| Date | 2015-02-23 09:41 +0100 |
| Organization | None |
| References | <CAPTjJmqx3s1a0LL4RLgVB1PsOfyF9ryy6nwHwOwrQs1Zx2Hd-Q@mail.gmail.com> <85vbit73jd.fsf@benfinney.id.au> <CAPTjJmqY0ZMr-xMgJ1hsBc1mPMeML0q-QuRsU0Mnm8sngU64yg@mail.gmail.com> <85r3th711e.fsf@benfinney.id.au> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.19059.1424680918.18130.python-list@python.org> (permalink) |
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.
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: Unrecognized backslash escapes in string literals Peter Otten <__peter__@web.de> - 2015-02-23 09:41 +0100
csiph-web