Andrey França Andrey França - 26 days ago 12
Python Question

Difference between comments in python # and """

Starting to program in python, I see some scripts with comments using

#
and
""" comments """
I would like to find out the difference between these two ways to comment.

Answer

Best thing would be to read https://www.python.org/dev/peps/pep-0008/, but since it is longish, here is three liner:

  • Comments start with # and are not part of the code.
  • String (delimited by """ """) is actually called a docstring and is used on special places for defined purposes (briefely: first thing in module or function describing the module or function) and is actually accessible in the code (so it is a part of the program, it is not a comment).
Comments