Andrey França Andrey França - 1 year ago 73
Python Question

Difference between comments in python # and """

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

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

Answer Source

Best thing would be to read, 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).
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download