• Xander Stevenson

Comments in Python

Updated: Dec 16, 2020

# this is a comment


# this is going to be a multi-line comment.

#

# see, I told you, multiple lines


x = 3852.43 # this is an inline comment, try to avoid these


""" This is actually called a docstring.

It can span multiple lines and

A docstring is a string literal that occurs as the first statement in a module, function, class, or method definition. Such a docstring becomes the __doc__ special attribute of that object.

"""


'''useless triple-quoted

multi-line

string'''


Strings, even docstrings, aren't technically comments (they're evaluated, comments aren't)


Sources:

https://www.python.org/dev/peps/pep-0008/#comments

https://www.python.org/dev/peps/pep-0257/


PEPs are formatting and naming conventions for the Python language

0 views0 comments

Xander Stevenson's

  • linkedin logo
  • github logo