What is prefered: 'string' or "string"? (Should be in PEP8 ?)
Petr Prikryl
Answer.via.news.please.prikrylp at nospam_skil.cz
Wed Apr 24 01:17:45 EDT 2002
Well, I have meant what quotes should I use in cases
when only single or only double are to be used (i.e.
when I do not want to include the opposite inside
the string. Read it what *style* is prefered.
"Philipp Lenssen" wrote...
> "Petr Prikryl" wrote...
> > In other words, should I prefer writing:
> > s1 = 'first string'
> > or
> > s2 = "second string"
>
> For XHTML string output, I prefer single quotes
> because I don't have to escape double-quotes
> within the string, e.g.:
> s += '<img src="..." alt="" />'
Here you can also write:
s += "<img src='...' alt='' />"
... so this does not make it clearer ;-)
Petr
More information about the Python-list
mailing list