PyDocs

Command-line interface libraries

optparse

A powerful, extensible, and easy-to-use option parser.

Simple usage example:

   from optparse import OptionParser

   parser = OptionParser()
   parser.add_option("-f", "--file", dest="filename",
                     help="write report to FILE", 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()
Symbols in optparse

a

AmbiguousOptionError
Raised if an ambiguous option is seen on the command line.

b

BadOptionError
Raised if an invalid option is seen on the command line.

o

Option
Instance attributes: _short_opts : [string] _long_opts : [string]
OptionConflictError
Raised if conflicting options are added to an OptionParser.
OptionError
Raised if an Option instance is created with invalid or inconsistent arguments.
OptionParser
Class attributes: standard_option_list : [Option] list of standard options that will be accepted by all instances of this parser class (intended to be overridden by subclasses).
OptionValueError
Raised if an invalid option value is encountered on the command line.

v

Values
An object holding parsed argument names and values as attributes.