Since many of my scripts share the same structure, I have a little template that I use for new scripts. I have a makepy command that copies this template to a new script.
# Miki Tebeka
if argv is None:
argv = sys.argv
from optparse import OptionParser
parser = OptionParser("usage: %prog ")
opts, args = parser.parse_args(argv[1:])
if len(args) != 1:
parser.error("wrong number of arguments") # Will exit
if __name__ == "__main__":
As you can see, there is a place holder for the script documentation string. There is also a main function (inspired by Guido) and also a template for calling optparse command line parser module (most of my scripts take one argument, so this is the default).