What is prefered: 'string' or "string"? (Should be in PEP8 ?)

John Baxter jwbaxter at spamcop.net
Wed Apr 24 22:24:46 EDT 2002


In article <aa5f7l$uck$1 at news.nextra.cz>,
 "Petr Prikryl" <Answer.via.news.please.prikrylp at nospam_skil.cz> wrote:

> 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.

I use single quote (that is, apostrophe) to avoid a shift key 
manipulation.  Unless I forget.  And of course if the string begins with 
a shifted character, the manipulation is deferred, not avoided.

If for some reason I want a string to be
    Eggs!
I'll use double quote.  Unless I forget.

In other words, you probably shouldn't follow my example.  And you may 
possibly detect that I don't find it a major issue.

  --John (my opinions seem to be my own...no one has claimed them yet in 
60 years)



More information about the Python-list mailing list