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

From: David Fraser (davidf_at_sjsoft.com)
Date: 10/05/04


Date: Tue, 05 Oct 2004 08:17:21 +0200

Russell Nelson wrote:
> Jef Raskin (namedropping) has pointed me at a neat scheme for quoting
> arbitrary textual matter called "Mandis quotes". Since google is
> ignorant of the phrase, I presume that Jef made it up. It is
> disgustingly simple, and very Pythonesque. Here's how it works: If
> you have a string that doesn't have any single quotes in it, you
> surround the string by a pair of doubled single quotes. ''Like
> this''. No backslash interpolation. If you want a character in
> there, you put it in there (yes, I know, stand down your armies).
> Clearly, then, any character except a single quote can go into one of
> these strings. If you need to put a single quote in, then you put
> an arbitrary string in-between the single quotes which does NOT
> appear in the string. For example, "Bill's house" becomes
> 'x'Bill's house'x'.
>
> More formally, a mandis quote is a pair of tokens surrounding a
> completely arbitrary sequence of bytes. These tokens are comprised of
> a possibly null sequence of characters preceded by and followed by a
> single quote.
>
> To save time, here's why this pre-PEP proposal sucks in decreasing
> order of severity:
>
> o Python source is typically represented, not as an arbitrary string
> of ASCII or Unicode characters, but instead as a sequence of lines
> separated by the native line terminator (e.g. CRLF, LF, or CR).
>
> o Editors are not all up to the task of inserting arbitrary
> characters into strings (although they SHOULD).
>
> o Email cannot withstand arbitrary strings of characters (although
> quoted-printable suffices).
>
> o Some distinct Unicode characters are represented using the same
> glyph, so that information is lost when text gets printed (but
> that's more of a Unicode stupidism.)
>
> Obviously, the justification for it is that it eliminates ", ', r",
> r', """, and ''' from the syntax, replacing them by a single 'x' that
> suffices for everything. Makes the code easier to read (only one
> visual element), easier to parse, and easier to write, because you
> don't need to decide which literal method to use.

And distinctly ugly. I much prefer """ or ''' :-)



Relevant Pages

  • Re: Mandis Quotes (aka retiring """ and )
    ... >surround the string by a pair of doubled single quotes. ... > of ASCII or Unicode characters, but instead as a sequence of lines ... Quoting "arbitrary" text also involves the issue of encoding, ...
    (comp.lang.python)
  • Re: cant compare a varchar properly using WHERE
    ... LIKE is for finding strings that share a common pattern of characters ... Martin & Martinez but would not return Gilmartin. ... beginning or end of the string. ... > I was missing single quotes. ...
    (microsoft.public.sqlserver.programming)
  • Mandis Quotes (aka retiring """ and )
    ... arbitrary textual matter called "Mandis quotes". ... surround the string by a pair of doubled single quotes. ... of ASCII or Unicode characters, but instead as a sequence of lines ...
    (comp.lang.python)
  • Re: CLisp case sensitivity
    ... Adam Warner writes: ... > the size of a character the length of an arbitrary string will be ... > characters are a fixed size of n-bits or that characters must be ... to do with the value LENGTH returns when passed a string. ...
    (comp.lang.lisp)
  • Re: Getting Rid of the Nulls
    ... string newString = oldString.Trim(note the single quotes, ... > to converter a byte array from the registry to a string. ... but I end up with a bunch of null characters after ... > The only thing I can think of is to convert the string to a char array ...
    (microsoft.public.dotnet.languages.csharp)