Py-dea: Streamline string literals now!

Nathan Rice nathan.alexander.rice at gmail.com
Wed Dec 28 17:24:47 EST 2011


On Wed, Dec 28, 2011 at 4:42 PM, Chris Angelico <rosuav at gmail.com> wrote:
> On Thu, Dec 29, 2011 at 8:24 AM, Nathan Rice
> <nathan.alexander.rice at 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.

I think you read more into my statement than was intended.  Parens are
bad like nested quotes are bad in the sense that they made statements
difficult to read and confusing.

While it is entirely possible to parse nested strings automatically in
a probabilistic manner with nearly flawless accuracy by examining
everything between the start and end of the line, generally I feel
that people are uncomfortable with probabilistic techniques in the
realm of programming :)  Best just to make the user be explicit.

Nathan



More information about the Python-list mailing list