0
What is the difference between docstring and an ordinary string?
I am new to this python and I am getting it.
1 Antwort
0
You can get a docstring from outside where it is defined, using the help function.
def f() :
"Your doc string"
# function code here
help(f)
output: That docstring of yours.
So type-wise a docstring is just an ordinary string; but if you put it in the right place (beginning of a function, class or module), Python enables you to use this string for informing the user of that code. That's what makes it a 'doc string'.