Building Blocks of Python: Comments

 Building Blocks of Python

3. Comments

Comments in Python are used to convey the ides behind the code 


For single line comment: Use '#' in front of the line



For multiple line comment:

triple single quotes ('''   '''') or  triple double quotes ("""   """)




Docstring

Ref : https://www.datacamp.com/community/tutorials/docstrings-python

  • It is a short form of Document string
  • Used to define what a function or class does
  • Docstrings are similar in spirit to commenting, but they are enhanced, more logical, and useful version of commenting. Docstrings act as documentation for the class, module, and packages.
  • On the other hand, Comments are mainly used to explain non-obvious portions of the code and can be useful for comments on Fixing bugs and tasks that are needed to be done.
  • Docstrings are represented with closing & opening quotes while comments start with a # at the beginning.
  • Note that comments can not be accessed with the built-in doc attribute and help function.





Comments