Consider the following code
class A:
def __init__(self):
"""This comment is visible"""
pass
variable = True
"""This is not visible"""
Then the output for help(A)
is:
Help on class A in module __main__:
class A(builtins.object)
| Methods defined here:
|
| __init__(self)
| This comment is visible
|
| ----------------------------------------------------------------------
| Data descriptors defined here:
|
| __dict__
| dictionary for instance variables (if defined)
|
| __weakref__
| list of weak references to the object (if defined)
|
| ----------------------------------------------------------------------
| Data and other attributes defined here:
|
| variable = True
Further the docstring for the init function can be obtained with help(A.__init__)
, but not for the A.variable
. Is there any way to obtain the docstring for class variables?