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


Groups > comp.lang.python > #18146

Re: Py-dea: Streamline string literals now!

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!news.albasani.net!feeder.erje.net!newsfeed.xs4all.nl!newsfeed6.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.002
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; '(at': 0.03; 'string.': 0.04; 'suppose': 0.05; 'programmers,': 0.07; 'delimiter': 0.09; 'subject:string': 0.09; 'am,': 0.12; 'received:209.85.214.174': 0.13; '(note': 0.16; 'apostrophe': 0.16; 'delimiters': 0.16; 'formats,': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'general.': 0.16; 'nest': 0.16; 'nesting': 0.16; 'parentheses': 0.16; "wouldn't": 0.17; 'wrote:': 0.18; 'dec': 0.22; '(or': 0.22; "doesn't": 0.22; 'header:In-Reply-To:1': 0.22; 'replacing': 0.23; 'string': 0.24; 'code': 0.25; 'message- id:@mail.gmail.com': 0.28; 'problem': 0.29; 'outer': 0.30; 'source': 0.31; 'thu,': 0.32; 'actual': 0.32; 'received:209.85.214': 0.32; 'pretty': 0.32; "can't": 0.32; 'rather': 0.33; 'there': 0.33; 'rules': 0.34; 'to:addr:python- list': 0.34; 'anything': 0.34; 'matter,': 0.34; 'issue': 0.35; 'vice': 0.35; 'similar': 0.36; 'starting': 0.36; 'uses': 0.36; 'but': 0.37; 'received:google.com': 0.37; 'received:209.85': 0.38; 'non': 0.38; 'either': 0.39; 'everyone': 0.39; 'received:209': 0.40; 'to:addr:python.org': 0.40; '2011': 0.61; 'guarantee': 0.65; 'subject:!': 0.67; 'intuitive': 0.67; '29,': 0.73; 'nathan': 0.84; 'interchange': 0.91; 'poorly': 0.91
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type:content-transfer-encoding; bh=4FSFZamqbOEIhuz9SLjlXd+k6EZpaZABIoJz6zHeN6s=; b=iDG0ICoeZNorryQDMSBj0Z+F5khAZI90kB30H2L+zqWaZvDmhgxajrqBAVZjG+9DF0 YjakrEGHU+EAwmQEOFEMjBDIN0VADiHV8IGwf0eBUWvghziqFPO/TzpgDcJJ4yTrv1Uv wqe3tQyQEtxTBJVXNBoUVSuCJg56SVvWowim8=
MIME-Version 1.0
In-Reply-To <CAOFbRmJOXHfv-tpUvaoEWWjmf9NNRVZi2JG0Zs4zion4hwu3Ow@mail.gmail.com>
References <280841b8-8674-4c1d-9a82-28982340a4b8@v24g2000yqk.googlegroups.com> <b2ced8f0-81af-44be-9cea-b6257c84d284@p13g2000yqd.googlegroups.com> <jdfvkl$at6$1@dough.gmane.org> <1325106214.5274.140661016836917@webmail.messagingengine.com> <CAOFbRmJOXHfv-tpUvaoEWWjmf9NNRVZi2JG0Zs4zion4hwu3Ow@mail.gmail.com>
Date Thu, 29 Dec 2011 08:42:46 +1100
Subject Re: Py-dea: Streamline string literals now!
From Chris Angelico <rosuav@gmail.com>
To python-list@python.org
Content-Type text/plain; charset=ISO-8859-1
Content-Transfer-Encoding quoted-printable
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.12
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://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 <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.4199.1325108570.27778.python-list@python.org> (permalink)
Lines 29
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1325108570 news.xs4all.nl 6946 [2001:888:2000:d::a6]:33009
X-Complaints-To abuse@xs4all.nl
Xref x330-a1.tempe.blueboxinc.net comp.lang.python:18146

Show key headers only | View raw


On Thu, Dec 29, 2011 at 8:24 AM, Nathan Rice
<nathan.alexander.rice@gmail.com> wrote:
> Quotes are obnoxious in the nesting sense because everyone uses quotes
> for string delimiters.  By the same token, quotes are wonderful
> because not only are they intuitive to programmers, but they are
> intuitive in general.  Parenthesis are pretty much in the same boat...
> I *HATE* them nested, but they are so intuitive that replacing them is
> a non starter;  Just write code that doesn't nest parenthesis.

Parentheses have different starting and ending delimiters and must be
'properly nested' (ie there must be exactly-matching inner parens
inside any given set of outer parens (note that English has similar
rules - you can't mis-nest parentheses (at any depth) in either
language)). You can't guarantee the same about quoted strings -
suppose the starting delimiter were ' and the ending " (or vice
versa), it still wouldn't deal with the issue of coming across an
apostrophe inside a quoted string.

In actual fact, the real problem is that quoted strings need to be
able to contain _anything_. The only true solution to that is
length-provided strings:

s = "4spam
q = "14Hello, world!\n

This works beautifully in interchange formats, but rather poorly in
source code (or, for that matter, anything editable).

ChrisA

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


Thread

Py-dea: Streamline string literals now! Rick Johnson <rantingrickjohnson@gmail.com> - 2011-12-27 19:49 -0800
  Re: Py-dea: Streamline string literals now! Chris Angelico <rosuav@gmail.com> - 2011-12-28 15:17 +1100
    Re: Py-dea: Streamline string literals now! Rick Johnson <rantingrickjohnson@gmail.com> - 2011-12-27 20:36 -0800
  Re: Py-dea: Streamline string literals now! Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-12-28 04:20 +0000
  Re: Py-dea: Streamline string literals now! Rick Johnson <rantingrickjohnson@gmail.com> - 2011-12-27 21:34 -0800
    Re: Py-dea: Streamline string literals now! Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-12-28 06:58 +0000
      Re: Py-dea: Streamline string literals now! Rick Johnson <rantingrickjohnson@gmail.com> - 2011-12-28 11:36 -0800
        Re: Py-dea: Streamline string literals now! Dominic Binks <dbinks@codeaurora.org> - 2011-12-28 12:10 -0800
        Re: Py-dea: Streamline string literals now! Lie Ryan <lie.1296@gmail.com> - 2011-12-29 07:13 +1100
        Re: Py-dea: Streamline string literals now! Ian Kelly <ian.g.kelly@gmail.com> - 2011-12-28 13:52 -0700
        Re: Py-dea: Streamline string literals now! Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-12-28 22:54 +0000
          Re: Py-dea: Streamline string literals now! Chris Angelico <rosuav@gmail.com> - 2011-12-29 10:08 +1100
          Re: Py-dea: Streamline string literals now! Dan Sommers <dan@tombstonezero.net> - 2011-12-29 01:44 +0000
          Re: Py-dea: Streamline string literals now! Lie Ryan <lie.1296@gmail.com> - 2011-12-30 10:19 +1100
          Re: Py-dea: Streamline string literals now! Chris Angelico <rosuav@gmail.com> - 2011-12-30 10:24 +1100
    Re: Py-dea: Streamline string literals now! Chris Angelico <rosuav@gmail.com> - 2011-12-28 18:47 +1100
    Re: Py-dea: Streamline string literals now! Lie Ryan <lie.1296@gmail.com> - 2011-12-29 07:53 +1100
    Re: Py-dea: Streamline string literals now! python@bdurham.com - 2011-12-28 16:03 -0500
    Re: Py-dea: Streamline string literals now! Nathan Rice <nathan.alexander.rice@gmail.com> - 2011-12-28 16:24 -0500
    Re: Py-dea: Streamline string literals now! Chris Angelico <rosuav@gmail.com> - 2011-12-29 08:42 +1100
    Re: Py-dea: Streamline string literals now! Nathan Rice <nathan.alexander.rice@gmail.com> - 2011-12-28 17:24 -0500
    Re: Py-dea: Streamline string literals now! Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2011-12-29 00:00 -0500

csiph-web