Introduction to Wagtail | Coders of Colour

Comments

Everything that follows a hash key (#) on that line is a comment. The Python interpreter does not take that line as part of the instructions it has to follow. This rule does not apply when the hash is placed in a string.

Comments help us or other developers understand the code we write. We can add descriptions of what the code does (or is meant to do) in order to remember what we did one week, month or year down the line.

# This line is a comment
print("Hello, world") # This is also a comment.
print("Hello"); print("World"); # This is an imporant line of code
# some instructions
print("This line doesn't have any #comments")

Block comments

Block comments allow us to write comments on several lines. In Python, we denote these with tripple quotes:

print('start')
'''
This little paragraph is
a
multiline comment
'''
print('end')
Edit this page on GitHub

On this page