Triple-double quote v.s. Double quote Triple-double quote v.s. Double quote python python

Triple-double quote v.s. Double quote


From the PEP8 Style Guide:

  • PEP 257 describes good docstring conventions. Note that mostimportantly, the """ that ends a multiline docstring should be on aline by itself, e.g.:

    """Return a foobangOptional plotz says to frobnicate the bizbaz first."""
  • For one liner docstrings, it's okay to keep the closing """ on thesame line.

PEP 257 recommends using triple quotes, even for one-line docstrings:

  • Triple quotes are used even though the string fits on one line. Thismakes it easy to later expand it.

Note that not even the Python standard library itself follows these recommendations consistently. For example,


They're both strings, so there is no difference. The preferred style is triple double quotes (PEP 257):

For consistency, always use """triple double quotes""" around docstrings.

Use r"""raw triple double quotes""" if you use any backslashes in your docstrings. For Unicode docstrings, use u"""Unicode triple-quoted strings""".


No, not really. If you are writing to a file, using triple quotes may be ideal, because you don't have to use "\n" in order to go a line down. Just make sure the quotes you start and end with are the same type(Double or Triple quotes). Here is a reliable resource if you have any more questions:

http://docs.python.org/release/1.5.1p1/tut/strings.html