Possible bug in string handling (with kludgy work-around)

Rick Johnson rantingrickjohnson at gmail.com
Tue Dec 27 19:57:04 EST 2011


On Dec 27, 3:38 pm, Terry Reedy <tjre... at udel.edu> wrote:
> On 12/27/2011 1:04 PM, Rick Johnson wrote:
>
> > But this brings up a very important topic. Why do we even need triple
> > quote string literals to span multiple lines? Good question, and one i
> > have never really mused on until now.
>
> I have, and the reason I thought of is that people, including me, too
> ofter forget or accidentally fail to properly close a string literal,

Yes, agreed.

> Color coding editors make it easier to catch such errors, but they were
> less common in 1991.

I would say the need for triple quote strings has passed long ago.
Like you say, since color lexers are ubiquitous now we don't need
them.

> And there is still uncolored interactive mode.

I don't see interactive command line programming as a problem. I mean,
who drops into a cmd line and starts writing paragraphs of string
literals? Typically, one would just make a few one-liner calls here or
there. Also, un-terminated string literal errors can be very
aggravating. Not because they are difficult to fix, no, but because
they are difficult to find! -- and sending me an error message
like...

 "Exception: Un-terminated string literal meets EOF! line: 50,466,638"

... is about as helpful as a bullet in my head!

If the interpreter finds itself at EOF BEFORE a string closes, don't
you think it would be more helpful to include the currently "opened"
strings START POSITION also? Heck, it would be wonderful to only have
the start position since the likely-hood of a string ending at EOF is
astronomical!

As an intelligent lad must know, the odds that the distance from any
given string's start position to it's end position is more likely to
be shorter than the distance from the string's beginning to the
freaking EOF! Ruby and Python are both guilty of this atrocity.



More information about the Python-list mailing list