The whole point of creating and populating an OptionParser is to call its parse_args() method:
(options, args) = parser.parse_args(args=None, options=None)
where the input parameters are
args
sys.argv[1:]
)
options
and the return values are
options
options
, or the
optparse.Values instance created by optparse
args
The most common usage is to supply neither keyword argument. If you
supply options
, it will be modified with repeated setattr()
calls (roughly one for every option argument stored to an option
destination) and returned by parse_args().
If parse_args() encounters any errors in the argument list, it calls the OptionParser's error() method with an appropriate end-user error message. This ultimately terminates your process with an exit status of 2 (the traditional Unix exit status for command-line errors).
See About this document... for information on suggesting changes.