The following very_important_fuction() function is given. Which attribute of this function stores docstring? def very_important_fuction():     """This is a very important function that always returns 1."""     return 1

Questions & AnswersCategory: PythonThe following very_important_fuction() function is given. Which attribute of this function stores docstring? def very_important_fuction():     """This is a very important function that always returns 1."""     return 1
Geek Boy Staff asked 2 years ago

The following very_important_fuction() function is given. Which attribute of this function stores docstring?

def very_important_fuction():
    """This is a very important function that always returns 1."""
    return 1

a. very_important_function.__name__
b. very_important_function.__doc__
c. very_important_function.__class__
d. very_important_function.__repr__
e. very_important_function.__code__

 

1 Answers
Geek Boy Staff answered 2 years ago

b. very_important_function.__doc__
Explanation

A docstring is a string literal that occurs as the first statement in a module, function, class, or method definition. Such a docstring becomes the __doc__ special attribute of that object.