Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder4.news.weretis.net!rt.uk.eu.org!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!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.006 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'string.': 0.05; 'string': 0.09; 'ambiguity': 0.09; 'escape': 0.09; 'literal': 0.09; 'cc:addr :python-list': 0.11; 'advocating': 0.16; 'backslash': 0.16; 'digits.': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'introduces': 0.16; 'literal,': 0.16; 'quoted': 0.16; 'syntaxerror:': 0.16; 'wrote:': 0.18; 'normally': 0.19; '>>>': 0.22; 'cc:addr:python.org': 0.22; 'cc:2**0': 0.24; 'handling': 0.26; 'header:In-Reply-To:1': 0.27; 'chris': 0.29; 'dec': 0.30; 'matching': 0.30; 'message-id:@mail.gmail.com': 0.30; "i'm": 0.30; "skip:' 10": 0.31; 'that.': 0.31; '"",': 0.31; '>>>>': 0.31; 'file': 0.32; 'regular': 0.32; 'another': 0.32; 'worked': 0.33; 'raw': 0.33; 'could': 0.34; 'editor': 0.35; 'received:google.com': 0.35; 'revert': 0.36; 'subject:?': 0.36; 'pm,': 0.38; 'does': 0.39; 'quote': 0.39; 'new': 0.61; 'skip:\xe2 10': 0.65; 'normal.': 0.68; '8bit%:43': 0.74; '(any': 0.84; 'to:none': 0.92; '2013': 0.98 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:cc :content-type:content-transfer-encoding; bh=hSIe5+j1zdyIXVWY972ClpNFuokcShgWLkhoL3KgK+E=; b=oNk3gv/agA4kNGjUjLzgIL9FIFBKn/Alr/QeDE8dtAa1OQ15+pR7zunDYAJMRukO1T TaOCG9K43gXZDeoGCmAKeHFE8aD6m71qPdxJZeuoyo7MZMI5dMiJUa6P3A2kAvZyVGqK P3UFPCwy5Bjs73IJ2y6pXI7PdWYx5u1ltFF5KBhcYKQnioPZ+A04BrbhgFWaSalKfnI8 m6pQOLJqdIeq/pMW8baQ7hzyeCPBk81VrdCLR9J4OGEcXAc+IgqqARa+9x/7EWE356Ju edvrt0G4lB6Z1b82UhrHa70YSY4UmSEWa7rnNZLRSE8+DcdZyLFpahMMv5XsbpYoxgw6 yFeQ== MIME-Version: 1.0 X-Received: by 10.66.164.136 with SMTP id yq8mr14777107pab.67.1386498399111; Sun, 08 Dec 2013 02:26:39 -0800 (PST) In-Reply-To: References: <27c0b454-62e9-410f-b05c-7c5fe306f8aa@googlegroups.com> Date: Sun, 8 Dec 2013 21:26:39 +1100 Subject: Re: Is It Bug? From: Chris Angelico Cc: "python-list@python.org" Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable 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: 35 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1386498404 news.xs4all.nl 2863 [2001:888:2000:d::a6]:59197 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:61283 On Sun, Dec 8, 2013 at 9:01 PM, Chris =E2=80=9CKwpolska=E2=80=9D Warrick wrote: > A raw string cannot end with a backslash. > >>>> r'a\a' > 'a\\a' >>>> r'a\' > File "", line 1 > r'a\' > ^ > SyntaxError: EOL while scanning string literal Incidentally, the solution to this would be to not use the backslash to escape the quote. That's what introduces the ambiguity. Instead, a raw literal could do as REXX does and double the quote to escape it. (Any whitespace and it's still concatenation as normal. I'm not advocating REXX's handling there.) >>> r"asdf""qwer" 'asdfqwer' If we had a new "pure string" that worked thus: >>> p"asdf""qwer" 'asdf"qwer' >>> p"\b""\d+""\b" '\\b"\\d+"\\b' which would be a regex matching quoted strings of digits. The only potential ambiguity would be in that closing the quote and opening another would normally revert to a regular string literal, where by this model it's still a pure string. Editor lexers would have to understand that. ChrisA