Why """, not '''?

Steven D'Aprano steve at REMOVE-THIS-cybersource.com.au
Wed Mar 5 16:59:19 EST 2008


On Wed, 05 Mar 2008 19:19:08 +0000, Matthew Woodcraft wrote:

> <MartinRinehart at gmail.com> wrote:
>> Why is """ the preferred delimiter for multi-line strings?
> 
> One advantage is that a dumb syntax highlighter is more likely to cope
> well if the content includes an apostrophe.

But if the content contains double-quote marks, the "dumb syntax 
highligher" is more likely to cope well if you use '''. And, let's be 
realistic here, a "dumb syntax highlighter" is more likely to not cope 
well with triple-quote strings *at all*.

Python treats ' and " symmetrically. There is no difference between them, 
except that:

(1) to type " requires using the shift-key, typing ' does not (on English 
QWERTY keyboards at least);

(2) in some typefaces " (double-quote) may be confused with '' (two 
single-quotes); and

(3) they look different.

Pretty basic stuff really.


-- 
Steven



More information about the Python-list mailing list