Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Re: Mandis Quotes (aka retiring """ and ''')

Reply
Thread Tools

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

 
 
Russell Nelson
Guest
Posts: n/a
 
      10-05-2004
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.
 
Reply With Quote
 
 
 
 
Jeff Shannon
Guest
Posts: n/a
 
      10-05-2004
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

 
Reply With Quote
 
 
 
 
Max M
Guest
Posts: n/a
 
      10-05-2004
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
 
Reply With Quote
 
Mel Wilson
Guest
Posts: n/a
 
      10-05-2004
In article <4162f2c1$0$202$(E-Mail Removed)>,
Max M <(E-Mail Removed)> 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.
 
Reply With Quote
 
Michael Sparks
Guest
Posts: n/a
 
      10-05-2004
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.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Scheduling a retiring exam after 3/31/2008 Louis Friend MCSE 14 03-30-2008 12:42 PM
Retiring Exams =?Utf-8?B?TGF1cmVuTTMzMzU=?= MCSE 45 07-25-2007 09:54 PM
Billy's retiring.... We're Soooo Screwed dominar Computer Security 2 06-22-2006 05:28 PM
Mandis Quotes (aka retiring """ and ''') Russell Nelson Python 12 10-05-2004 01:35 PM
are 70-216, 70-218 exams retiring on 31st dec 2004 ashok MCSA 1 06-23-2004 11:45 AM



Advertisments