What is prefered: 'string' or "string"? (Should be in PEP8 ?)
Skip Montanaro
skip at pobox.com
Tue Apr 23 12:07:33 EDT 2002
Petr> Being quite new to Python -- is there any preference of single or
Petr> double quotes when writing strings?
Not that I'm aware of. Coming from a C background, I personally tend to use
"..." for multi-character strings and '.' for single-character strings (in
the absence of any other constraints), but I don't adhere to it closely. In
particular, if I'm modifying someone else's code I try to mimic their usage.
When the strings contain apostrophes I try to use quotation marks and vice
versa. If strings contain both, I switch to triple-quoted strings. The
most hard-and-fast rule I adhere to is to try and avoid escaping embedded
apostrophes or quotation marks.
--
Skip Montanaro (skip at pobox.com - http://www.mojam.com/)
More information about the Python-list
mailing list