Python’s docstring are really the equivalent of Java’s javadocs. However, the neat thing about docstring is that it is actually a fully qualified Python object. Check out the example below.
PyHelloWorld – DocString style
class TestClass: """ Documentation for this test class... """ def helloWorld(self): """ HELLO WORLD DOCSTRING """ func=getattr(self,'helloWorld') docstr=func.__doc__ #<--- notice this? print docstr # 'quickie' main block test=TestClass() test.helloWorld()
Running the example below should print: “HELLO WORLD DOCSTRING”.
Note: I’ve also added this to my python programming notes.