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

Lumberjack lumber at jack.com
Tue Apr 23 15:56:03 EDT 2002


"Petr Prikryl" <Answer.via.news.please.prikrylp at nospam_skil.cz> wrote:
> Being quite new to Python -- is there any preference of
> single or double quotes when writing strings?

Strings containing vowels should be quoted with single quotes, except on 
Thursdays. Otherwise use doublequotes except the day after a full moon, in 
which case you should use the triple double quote mechanism. These rules 
will stand you in good stead. UNDER NO CIRCUMSTANCES SHOULD YOU USE ONLY 
ONE OF THE QUOTE CHARACTERS THROUGHOUT YOUR CODE. If you do the Earth will 
swallow you up and you will be looked down upon by others as too simple 
minded to be a programmer.

> While I do not consider this a problem for me (I can sleep
> quite well), I think that proposing some prefered way
> could make the look of Python sources more similar
> each other, i.e. slightly more understandable.

If you are sleeping well then clearly you aren't doing things correctly. 
While nature should take its course, one should never leave these things to 
chance and one can never have too many proposals.



More information about the Python-list mailing list