3

It seems like you can use both '''comments...''' and """comments...""" for multi-line comments. Is there any substantive difference between the two, or is it just a matter of preference?

2 Answers 2

8

These are not comments, they are docstrings. Python allows you to define multi-line strings using triplets of either apostrophes or quotation marks, but PEP 257 recommends using the quotation marks with docstrings for consistency. It has no effect on the contents of the string, however.

Sign up to request clarification or add additional context in comments.

Comments

1

It's a matter of preference. I would say it's more common to see double quotes with triple-quoted strings, especially when they're used as docstrings, but there's no functional difference between the two.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.