The various option actions all have slightly different requirements
and effects. Except for the ``help'' action, you must supply at least
one other keyword argument when creating the Option; the exact
requirements for each action are listed here.
The option must be followed by an argument, which is converted to a
value according to type and stored in dest. If
nargs > 1, multiple arguments will be consumed from the command
line; all will be converted according to type and stored to
dest as a tuple. See section 6.20.3,
``Option types,'' below.
If choices (a sequence of strings) is supplied, the type
defaults to ``choice''.
If type is not supplied, it defaults to ``string''.
If dest is not supplied, optparse derives a
destination from the first long option strings (e.g.,
--foo-bar becomes foo_bar). If there are no long
option strings, optparse derives a destination from the first
short option string (e.g., -f becomes f).
The option must be followed by an argument, which is appended to the
list in dest. If no default value for dest is supplied
(i.e. the default is None), an empty list is automatically created when
optparse first encounters this option on the command-line.
If nargs > 1, multiple arguments are consumed, and a tuple of
length nargs is appended to dest.
The defaults for type and dest are the same as for the
``store'' action.
Prints a complete help message for all the options in the current
option parser. The help message is constructed from the usage
string passed to OptionParser's constructor and the help
string passed to every option.
If no help string is supplied for an option, it will still be
listed in the help message. To omit an option entirely, use the
special value optparse.SUPPRESS_HELP.
If optparse sees either -h or
--help on the command line, it will print something
like the following help message to stdout:
usage: <yourscript> [options]
options:
-h, --help Show this help message and exit
-v Be moderately verbose
--file=FILENAME Input file to read data from
After printing the help message, optparse terminates your process
with sys.exit(0).
Prints the version number supplied to the OptionParser to
stdout and exits. The version number is actually formatted and
printed by the print_version() method of
OptionParser. Generally only relevant if the version
argument is supplied to the OptionParser constructor.