Return to Snippet

Revision: 19759
at October 30, 2009 05:16 by manatlan


Initial Code
from optparse import OptionParser

USAGE = """usage: %prog [options] <file1> <file2> ... """
   
if __name__ == "__main__":
    parser = OptionParser(usage=USAGE)
    parser.add_option("-o", "--output", dest="filename",
                      help="generate output infile", metavar="FILE")
    parser.add_option("-q", "--quiet",
                      action="store_false", dest="verbose", default=True,
                      help="don't print status messages to stdout")
    
    (options, args) = parser.parse_args()
    if not args:
        parser.print_help()
    else:
        print options.verbose
        print options.filename
        print args

Initial URL

                                

Initial Description

                                

Initial Title
python command line with optparse

Initial Tags
python

Initial Language
Python