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


Groups > comp.lang.python > #61283

Re: Is It Bug?

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 <rosuav@gmail.com>
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 <CAMw+j7JEEbj6Pt-ZGPT9dniyzokOKGvFd6ttTSDF9m5JO=GPfQ@mail.gmail.com>
References <27c0b454-62e9-410f-b05c-7c5fe306f8aa@googlegroups.com> <mailman.3713.1386464744.18130.python-list@python.org> <roy-756493.20224107122013@news.panix.com> <CAMw+j7JEEbj6Pt-ZGPT9dniyzokOKGvFd6ttTSDF9m5JO=GPfQ@mail.gmail.com>
Date Sun, 8 Dec 2013 21:26:39 +1100
Subject Re: Is It Bug?
From Chris Angelico <rosuav@gmail.com>
Cc "python-list@python.org" <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 <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.3722.1386498404.18130.python-list@python.org> (permalink)
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

Show key headers only | View raw


On Sun, Dec 8, 2013 at 9:01 PM, Chris “Kwpolska” Warrick
<kwpolska@gmail.com> wrote:
> A raw string cannot end with a backslash.
>
>>>> r'a\a'
> 'a\\a'
>>>> r'a\'
>   File "<stdin>", 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

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Is It Bug? Mahan Marwat <mahanmarwat@gmail.com> - 2013-12-07 16:59 -0800
  Re: Is It Bug? Chris Angelico <rosuav@gmail.com> - 2013-12-08 12:05 +1100
    Re: Is It Bug? Roy Smith <roy@panix.com> - 2013-12-07 20:22 -0500
      Re: Is It Bug? Chris “Kwpolska” Warrick <kwpolska@gmail.com> - 2013-12-08 11:01 +0100
      Re: Is It Bug? Chris Angelico <rosuav@gmail.com> - 2013-12-08 21:04 +1100
      Re: Is It Bug? Chris Angelico <rosuav@gmail.com> - 2013-12-08 21:26 +1100
  Re: Is It Bug? Mark Lawrence <breamoreboy@yahoo.co.uk> - 2013-12-08 01:06 +0000
  Re: Is It Bug? MRAB <python@mrabarnett.plus.com> - 2013-12-08 01:12 +0000
  Re: Is It Bug? Tim Roberts <timr@probo.com> - 2013-12-07 22:53 -0800
  Re: Is It Bug? Peter Otten <__peter__@web.de> - 2013-12-08 11:43 +0100

csiph-web