0
docstrings are just comments that are further explained or what is its main purpose? am not fully understanding the difference.
3 Réponses
+ 4
They integrate with the help() system. They automatically include newlines (retained formatting), don't translate special characters (like \t) and can be retrieved as a property.
The associated PEP:
https://www.python.org/dev/peps/pep-0257/
+ 2
docstrings are used to explain how the item functions. comments explain why something specifically is done at a certain section of code
+ 1
I don't really know how it is in Python, but in Java there is Javadoc (I guess it's quite equivalent to docstrings) and you can generate a nice HTML page as you can find when you search for documentation on internet.