+ 1
Everything between the triple quotes is the function’s docstring, which documents what the function does. A docstring, if it exists, must be the first thing defined in a function (that is, on the next line after the function declaration). You don’t technically need to give your function a docstring, but you always should. Python gives you an added incentive: the docstring is available at runtime as an attribute of the function.
Many Python IDEs use the docstring to provide context-sensitive documentation, so that when you type a function name, its docstring appears as a tooltip. This can be incredibly helpful, but it’s only as good as the docstrings you write.
(from www.diveintopython3.net) (I recommend this online book).
+ 5
Docstrings can be used as multi-line comments, although it's not really their primary purpose. They are used to define multi-line strings of the shape exactly as typed (with spaces, tabs, newlines and other whitespace).
+ 3
doc strings help to provide information for e.g. a class or function
def myfunc():
"""
This is my function
"""
if you now call:
help(myfunc)
it will output:
This is my function
+ 2
If you use '#', you can write single line comments only. But sometimes when you need to write paragraphs of comments, its not comfortable to write # for every line. So if you use *'''* at the beginning and end, you don't need to use # for every line. As simple as That :)