Python DocStrings

Python has a nifty feature called documentation strings which is commonly mentioned by its shorter name docstrings. We can even get back the docstring from, let say a function, when the program is actually running! 

def  sayHello():
         ”’This function prints Hello”’
         print “Hello”

print sayHello()
print sayHello.__doc__ 

Output:

  Hello
  This function prints Hello

To write the documentation of sys:

import pydoc

pydoc.writedoc(“sys”)

note the sys.html is written in the same path.

One Response to “Python DocStrings”

  1. girish Says:

    hi
    watch http://www.canaravideo.com which has simmillar topic video clippings

Leave a Reply