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


Groups > comp.lang.python > #18153

Re: Py-dea: Streamline string literals now!

From Dan Sommers <dan@tombstonezero.net>
Subject Re: Py-dea: Streamline string literals now!
Date 2011-12-29 01:44 +0000
References <280841b8-8674-4c1d-9a82-28982340a4b8@v24g2000yqk.googlegroups.com> <b2ced8f0-81af-44be-9cea-b6257c84d284@p13g2000yqd.googlegroups.com> <4efabe1d$0$29966$c3e8da3$5496439d@news.astraweb.com> <c233420e-81e8-49be-baa2-12f71f5fc09e@n39g2000yqh.googlegroups.com> <4efb9e18$0$29966$c3e8da3$5496439d@news.astraweb.com>
Newsgroups comp.lang.python
Message-ID <mailman.4207.1325123074.27778.python-list@python.org> (permalink)

Show all headers | View raw


On Wed, 28 Dec 2011 22:54:16 +0000, Steven D'Aprano wrote:

> On Wed, 28 Dec 2011 11:36:17 -0800, Rick Johnson wrote:
> 
>> The point is people, we should be using string delimiters that are
>> ANYTHING besides " and '. Stop being a sheep and use your brain!
> 
> "ANYTHING", hey?
> 
> I propose we use ئ and ร as the opening and closing string delimiters.
> Problem solved!

Why stop at pre-determined, literal delimiters?  That's way too easy on 
the parser, whether that parser is a computer or a person.

__string_delimiter__ = Ω  # magic syntax; no quotes needed

x = ΩhelloΩ

__string_delimiter__ = #  # that first # isn't a comment marker

x = # this isn't a comment; it's part of the string
this is a multi-line string
#

__string_delimiter__ = ''  # the delimiter is delimited by whitespace
# now I can have comments, again, too

x = ''"hello"''  # now x contains two double-quote characters

I'm sure that the implementation is trivial, and it's so much easier to 
write strings that contain quotes (not to mention how easy it is to read 
those strings back later).

-- 
Dan

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