7 Respostas
+ 3
Thank you so much my friends.............
+ 7
Yes, of course, Docstrings act as multiline comments in python that are ignored while running the program. Because "#" supports only 1 line comments
+ 7
𝐊𝐢𝐢𝐛𝐨 𝐆𝐡𝐚𝐲𝐚𝐥, your definition of docstring is incorrect, Kiibo.
As Code Crasher pointed out, a doc string is a specific documentation tool.
If you start a module, class, function or method with a string literal - ANY string literal - it will be stored in the attribute __doc__ of that m, c, f or m.
Instead of using help, pydoc etc. you can also write:
print(f.__doc__)
This...
'''Hello
Kiibo''"
... is just one way to write a string. It is not different to any other string literal you write.
+ 5
Kiibo, do you know what a docstring is?
It is what will be printed if you use the help function on your function, module, class or whatever.
def f():
'Hello World'
help(f)
# Output: Hello World
For this to work, the string has to be at the top.
+ 4
The only two things a docstring has to do are:
1.) be a string, and
2.) be at the beginning of the function.
+ 3
Wrong:
def f():
kiibo = "I'm wrong here"
'docstring'
Correct:
def f():
'docstring'
kiibo = 'attaboy'
0
Can a docstring contain multiple lines of text?
docstring can also overlap to multiple lines, just like multi line comments. docstring with help of triple-quotation mark.
answer: yes