+ 3
Can I say Doctstrings as multiple line comment only? Or it is something more?
2 Réponses
+ 5
Docstring is similar to the #comment. Docstrings in particular are placed right after a new function is defined.
Ex. def newfunction():
"""This is the docstring that explains what newfunction does"""
Now if you use help(newfunction) , the docstring is printed. Docstrings are used with help() if you have a mountain of code and need to know what a function does
+ 3
Not only multi-lines comments, you can assign a variable with multi-lines string literals ;)
( and both triple "doube quotes" and triple "single quotes" are valid... )