Path: csiph.com!usenet.pasdenom.info!news.franciliens.net!fdn.fr!usenet-fr.net!nerim.net!novso.com!newsfeed.xs4all.nl!newsfeed2a.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.002 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'static': 0.04; 'motivated': 0.05; 'string': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'subject:string': 0.09; 'tmp': 0.09; 'backslash': 0.16; 'backslashes': 0.16; 'combinations': 0.16; 'compiler.': 0.16; 'docstring': 0.16; 'finney': 0.16; 'highlight': 0.16; 'received:80.91.229.3': 0.16; 'received:dip0.t-ipconnect.de': 0.16; 'received:plane.gmane.org': 0.16; 'received:t-ipconnect.de': 0.16; 'string:': 0.16; 'tool.': 0.16; 'appropriate': 0.16; 'wrote:': 0.18; 'module': 0.19; 'header :User-Agent:1': 0.23; 'helpful': 0.24; 'header:X-Complaints-To:1': 0.27; 'chris': 0.29; 'said,': 0.30; 'code': 0.31; 'changed.': 0.31; 'constant': 0.31; 'produces': 0.31; 'writes:': 0.31; 'probably': 0.32; 'another': 0.32; 'quite': 0.32; 'maybe': 0.34; 'could': 0.34; "can't": 0.35; 'something': 0.35; 'but': 0.35; 'there': 0.35; 'turn': 0.37; 'being': 0.38; 'implement': 0.38; 'ben': 0.38; 'depends': 0.38; 'to:addr:python-list': 0.38; 'explain': 0.39; 'though,': 0.39; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'read': 0.60; 'skip:* 10': 0.61; "you're": 0.61; 'such': 0.63; 'more': 0.64; 'special': 0.74; 'analysis': 0.75; "it'd": 0.84; 'mind:': 0.84; 'warning.': 0.84; 'approach.': 0.91 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Peter Otten <__peter__@web.de> Subject: Re: Unrecognized backslash escapes in string literals Date: Mon, 23 Feb 2015 09:41:42 +0100 Organization: None References: <85vbit73jd.fsf@benfinney.id.au> <85r3th711e.fsf@benfinney.id.au> Mime-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 7Bit X-Gmane-NNTP-Posting-Host: p57bd8277.dip0.t-ipconnect.de User-Agent: KNode/4.13.3 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 33 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1424680918 news.xs4all.nl 2894 [2001:888:2000:d::a6]:44861 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:86202 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 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.