+ 3

What is the importance of the underscores used before and after "doc" when printing a multi line comment?

__doc__

5th Oct 2019, 8:23 PM
Divine Darkey
Divine Darkey - avatar
3 odpowiedzi
+ 2
Please tag your question with python. The __doc__ is a builtin attribute of every object (class or function) on python. It is auto generated from the triple double quote docstring that comes immediately after the object header. https://code.sololearn.com/c4hPmv1aeS5e/?ref=app
6th Oct 2019, 4:35 AM
Tibor Santa
Tibor Santa - avatar
+ 2
I never knew it was an in-built attribute but what I know is that underscores are sometimes placed in front of such statement to tell it to access the value within the class not an external resource.
6th Oct 2019, 7:44 AM
Divine Darkey
Divine Darkey - avatar
0
Typically if a variable in python begins with underscore, it is considered 'private' (do not modify this from the outside) Also double underscore (also called 'dunder' has special meanings. Read this for more details https://dbader.org/blog/meaning-of-underscores-in-python
6th Oct 2019, 12:07 PM
Tibor Santa
Tibor Santa - avatar