0

docstrings are just comments that are further explained or what is its main purpose? am not fully understanding the difference.

6th Nov 2016, 9:07 PM
Galata Hassan
Galata Hassan - avatar
3 Antworten
+ 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/
6th Nov 2016, 11:27 PM
Kirk Schafer
Kirk Schafer - avatar
+ 2
docstrings are used to explain how the item functions. comments explain why something specifically is done at a certain section of code
7th Nov 2016, 2:49 AM
Alex Schrichte
Alex Schrichte - avatar
+ 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.
6th Nov 2016, 9:57 PM
Pierre Varlez
Pierre Varlez - avatar