Skip to main content

4.6) Docstrings


It's usual to start your program with several lines of comments indicating the name of the program, what the program is for, how to use it and who wrote it when.

To avoid having to put a # before every line of these program-header comments, it’s recommend to use the triple double quotation mark instead.

Type this program and execute it:

"""
This program prints 'Hello, World!'
Author: John Doe
"""
print "Hello, World!"

You are essentially creating a string, but not doing anything with it. It is called Docstring. These docstrings are used by documentation tools and the help() function. help(math.sin) prints out the docstring of the function math.sin().