Printing Docstring of function from inside the function
def myfunc():
""" this is myfunc """
doc = myfunc.__doc__
class MyClass:
def bar(self):
""" this is bar """
doc = MyClass.bar.__doc__
Printing Docstring of function from inside the function: Alternate Method : similar method can be used from outside the function itself.
def myfunc():
""" this is myfunc """
doc = globals()["myfunc"].__doc__
class MyClass:
def bar(self):
""" this is bar """
doc = globals()["MyClass"].bar.__doc__