How do I make multi-line comments? Most languages have block comment symbols like:
JavaScript
x
4
1
/*
2
3
*/
4
Advertisement
Answer
You can use triple-quoted strings. When they’re not a docstring (the first thing in a class/function/module), they are ignored.
JavaScript
1
5
1
'''
2
This is a multiline
3
comment.
4
'''
5
(Make sure to indent the leading '''
appropriately to avoid an IndentationError
.)
Guido van Rossum (creator of Python) tweeted this as a “pro tip”.
However, Python’s style guide, PEP8, favors using consecutive single-line comments, like this:
JavaScript
1
3
1
# This is a multiline
2
# comment.
3
…and this is also what you’ll find in many projects. Text editors usually have a shortcut to do this easily.