Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python code comments

Tags:

python

In C# and through Visual Studio, it is possible to comment your functions, so you can tell whoever is using your class what the input arguments should be, what it is supposed to return, etc. Is there anything remotely similar in python?

like image 920
devoured elysium Avatar asked Jul 04 '26 11:07

devoured elysium


1 Answers

In Python you use docstrings like this:

def foo():
    """ Here is the docstring """

Basically you need to have a triple quoted string be on the first line of a function, class, or module to be considered a docstring.

Note: Actually I you don't have to use a triple quoted string but that is the convention. Any liter string will do but it is best to stick with convention and use the triple quoted string.

like image 114
Andrew Hare Avatar answered Jul 07 '26 00:07

Andrew Hare



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!