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.

Advertisements

One Response to Python DocStrings

  1. girish says:

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

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: