Re: Mandis Quotes (aka retiring """ and ''')

Discussion in 'Python' started by Russell Nelson, Oct 5, 2004.

  1. Eric Pederson writes:
    > So possible examples might be:


    Choose poor examples, and then criticize them as poor choices?

    > 'xx'somebody's mother'xx'


    How about '.'somebody's mother'.'
    Or '-'somebody's mother'-'

    > <quote>somebody's body<quote>
    >
    > or would we then worry that we might want to quote some angle
    > bracketed mark-up?


    I sure would.

    > [I like '''triple quotes''' though if they ever catch on in the mainstream, they'll be useless - because they will wind up in strings]


    Exactly. It really would be better to have one(1) string literal
    which can quote anything without reverting to backslashing. Why one?
    Simpler parsing, simpler learning of the language, fewer choices to
    make while programming.

    --
    --My blog is at angry-economist.russnelson.com | Violence never solves
    Crynwr sells support for free software | PGPok | problems, it just changes
    521 Pleasant Valley Rd. | +1 212-202-2318 voice | them into more subtle
    Potsdam, NY 13676-3213 | FWD# 404529 via VOIP | problems.
     
    Russell Nelson, Oct 5, 2004
    #1
    1. Advertising

  2. Russell Nelson

    Jeff Shannon Guest

    Russell Nelson wrote:

    >It really would be better to have one(1) string literal
    >which can quote anything without reverting to backslashing. Why one?
    >Simpler parsing, simpler learning of the language, fewer choices to
    >make while programming.
    >
    >


    The problem being, of course, that you need to find a string literal
    that will *never*, *ever* appear inside of a string literal. Even in
    strings that contain language describing the quoting of string
    literals. If there's any possibility of the need to display that
    particular string literal, then you need to either have an alternate
    (and what if you need both alternates in a string? then you need a third
    alternate...) or you need to have a way of escaping it. ISTM that these
    elaborate Mandis-quote schemes may significantly reduce the odds of
    needing to escape a string literal, but the cost (in clarity,
    transparency, and most importantly, ability to manipulate your code in
    anything other than an advanced, complying editor) is pretty high. I
    find '''triple quotes''' a lot easier to understand/explain than this
    scheme of defining arbitrary delimiters.

    Jeff Shannon
    Technician/Programmer
    Credit International
     
    Jeff Shannon, Oct 5, 2004
    #2
    1. Advertising

  3. Russell Nelson

    Max M Guest

    Jeff Shannon wrote:
    > Russell Nelson wrote:


    > ISTM that these
    > elaborate Mandis-quote schemes may significantly reduce the odds of
    > needing to escape a string literal, but the cost (in clarity,
    > transparency, and most importantly, ability to manipulate your code in
    > anything other than an advanced, complying editor) is pretty high. I
    > find '''triple quotes''' a lot easier to understand/explain than this
    > scheme of defining arbitrary delimiters.


    In fact, the triple quotes are just special cases of the Mandis quotes,
    and would still be legal. No?


    '''Hello world'''

    'x'Hello world'x'

    '4242424242'Hello world'4242424242'

    same difference

    --

    hilsen/regards Max M, Denmark

    http://www.mxm.dk/
    IT's Mad Science
     
    Max M, Oct 5, 2004
    #3
  4. Russell Nelson

    Mel Wilson Guest

    Re: Mandis Quotes (aka retiring """ and ''')

    In article <4162f2c1$0$202$>,
    Max M <> wrote:
    >Jeff Shannon wrote:
    >> Russell Nelson wrote:
    >> ISTM that these
    >> elaborate Mandis-quote schemes may significantly reduce the odds of
    >> needing to escape a string literal, but the cost (in clarity,
    >> transparency, and most importantly, ability to manipulate your code in
    >> anything other than an advanced, complying editor) is pretty high. I
    >> find '''triple quotes''' a lot easier to understand/explain than this
    >> scheme of defining arbitrary delimiters.

    >
    >In fact, the triple quotes are just special cases of the Mandis quotes,
    >and would still be legal. No?
    >
    >
    >'''Hello world'''


    However the sequence of distinguishing bytes making up
    one end of a Mandis quote is "possibly null" (viz. original
    post) so this could either mean

    "Hello world"
    or
    "'Hello world'"

    depending.

    When I read _The Humane User Interface_ I came away with
    the impression that the UI would be great for
    non-programming-users, but lousy for programming-users,
    because of the meta-stuff that programmers routinely deal
    with.

    Regards. Mel.
     
    Mel Wilson, Oct 5, 2004
    #4
  5. Max M wrote:

    > Jeff Shannon wrote:
    >> Russell Nelson wrote:

    >
    >> ISTM that these
    >> elaborate Mandis-quote schemes may significantly reduce the odds of
    >> needing to escape a string literal, but the cost (in clarity,
    >> transparency, and most importantly, ability to manipulate your code in
    >> anything other than an advanced, complying editor) is pretty high. I
    >> find '''triple quotes''' a lot easier to understand/explain than this
    >> scheme of defining arbitrary delimiters.

    >
    > In fact, the triple quotes are just special cases of the Mandis quotes,
    > and would still be legal. No?
    >
    >
    > '''Hello world'''
    >
    > 'x'Hello world'x'
    >
    > '4242424242'Hello world'4242424242'
    >
    > same difference


    Not really, no. " is essentially just '' as a single character. Indeed if
    you look at some forms of documentation (tends to be older docs), you'll
    often find things like ``this'' or ''this'' where these days people would
    write "this". (Some ancient keyboards didn't have " characters, which
    forced this approach)
    As a result you have:
    * 'this'
    * "this"
    * '''this'''

    Which is logically the same as the following, and can be viewed as the same,
    with an optimised second case.
    * 'this'
    * ''this''
    * '''this'''

    Likewise when writing, many people will interchange ' with ", hence '''
    whilst odd isn't suprising to see - it's a logical extension, and still
    looks like a form of quote. I've taken to using this incidentally in block
    quotes in emails and interestingly I've not had any comments as to what I
    mean by it.

    However ...
    > 'x'Hello world'x'
    > '4242424242'Hello world'4242424242'


    .... are completely different kettles of fish.

    to me I can't help reading those as mistypings of
    > 'x', Hello world, 'x'
    > '4242424242', Hello world, '4242424242'


    Which in turn look like mistypings. Far from being clearer you end up with
    something that looks like typoes even when you know the rules. Indeed how
    could you tell what the intent here was if you were presented with it and
    knew there was a bug, and that there was an issue in the code?

    foo = 'this'the'other'andnot'this' ?

    Is that legal ? Does that mean:
    * '''this'the'other'andnot'this'''

    or was it a rushed and they meant:
    foo = 'this',the,'other',andnot,'this' ?

    Python often tends to do things which even if suprising are fairly obvious
    what they mean to the casual observer. 'this' isn't like any other
    mainstream programing language and as a result would confused people much
    more than a simple 'this'.

    (Is that a mandis quote or is it a sentance that makes no sense? :)

    In many respects it's much like various tagging formats, but misses some
    advantages eg xml:
    <this> isn't like any other mainstream programing language and as a result
    would confused people much more than a simple </this>

    Unlike mandis quotes here we have a clear indication that the thing the
    "this"s are distinct from the data. Also it's clear that the following is a
    mistake:
    <this> isn't like any other mainstream programing language and as a result
    would confused people like <this> much more than a simple </this>

    Whereas is the following a mistake?
    'this' isn't like any other mainstream programing language and as a result
    would confused people like 'this' much more than a simple 'this'

    Personally I would say that if someone was _really_ interested in discarding
    quoting schemes, there's one easy way of doing so - only ever use ''' and
    """. It's trivial, it's implemented and is as you say very similar to
    Mandis quotes, but doesn't allow for uses that make maintenance harder.

    However personally I see a benefit between having """, ", ''', and ' - the
    single quote form makes it explicit that the string should terminate on
    that line, and makes it *a lot* simpler to find out if a quote is missing:
    foo = 'th,is',the,'oth,er',a'n,'dn',ot,'this' ?
    Whereas """ makes it clear the string *doesn't* terminate on the same line.

    Mandis quotes don't really help with conveying _either_ intent.

    Regards,


    Michael.
     
    Michael Sparks, Oct 5, 2004
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Chris White

    Quotes/Double Quotes in Image Control

    Chris White, Sep 22, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    4,852
    Hermit Dave
    Sep 22, 2004
  2. Chris
    Replies:
    1
    Views:
    13,644
    Oisin
    Mar 24, 2006
  3. Russell Nelson

    Mandis Quotes (aka retiring """ and ''')

    Russell Nelson, Oct 4, 2004, in forum: Python
    Replies:
    12
    Views:
    506
    Max M
    Oct 5, 2004
  4. James Edward Gray II

    Current Quizmaster Retiring

    James Edward Gray II, Nov 9, 2007, in forum: Ruby
    Replies:
    27
    Views:
    289
    thefed
    Nov 12, 2007
  5. Matthew Moss
    Replies:
    36
    Views:
    342
    James Gray
    Jan 17, 2009
Loading...

Share This Page