Python Multiline Comments and Docstrings Explained

In python there is no true multiline comment syntax like other programming languages. We use # in front of each line to treat them as comment. Another way but not exactly comment is the use of Docstring. This can be used with classes, functions and modules. Docstring is a special string literal and must be the first thing inside a class, function or a module. Docstring are written inside triple quotes. To get the content of a docstring we use anyone of the below - 1. print(set_age.__doc__) 2. help(set_age) "set_age" mentioned above is the name of a function. #Python #Programming

  • text

To view or add a comment, sign in

Explore content categories