No:
2.4.1. String and Bytes literals
...In plain English: Both types of literals can be enclosed in matching single quotes (
') or double quotes ("). They can also be enclosed in matching groups of three single or double quotes (these are generally referred to as triple-quoted strings). The backslash (\) character is used to escape characters that otherwise have a special meaning, such as newline, backslash itself, or the quote character...
Python is one of the few (?) languages where ' and " have identical functionality. The choice for me usually depends on what is inside. If I'm going to quote a string that has single quotes within it I'll use double quotes and visa versa, to cut down on having to escape characters in the string.
Examples:
"this doesn't require escaping the single quote"
'she said "quoting is easy in python"'
This is documented on the "String Literals" page of the python documentation:
- http://docs.python.org/2/reference/lexical_analysis.html#string-literals (2.x)
- http://docs.python.org/3/reference/lexical_analysis.html#string-and-bytes-literals (3.x)
No, there isn't. When the string contains a single quote, it's easier to enclose it in double quotes, and vice versa. Other than this, my advice would be to pick a style and stick to it.
Another useful type of string literals are triple-quoted strings that can span multiple lines:
s = """string literal...
...continues on second line...
...and ends here"""
Again, it's up to you whether to use single or double quotes for this.
Lastly, I'd like to mention "raw string literals". These are enclosed in r"..." or r'...' and prevent escape sequences (such as \n) from being parsed as such. Among other things, raw string literals are very handy for specifying regular expressions.
Read more about Python string literals here.
While it's true that there is no difference between one and the other, I encountered a lot of the following behavior in the opensource community:
"for text that is supposed to be read (email, feeback, execption, etc)'for data text (key dict, function arguments, etc)- triple
"for any docstring or text that includes"and'