6.21.3.5 Querying and manipulating your option parser
From Python PEP
6.21.3.5 Querying and manipulating your option parser
Sometimes, it's useful to poke around your option parser and see what's there. OptionParser provides a couple of methods to help you out:
- Return true if the OptionParser has an option with
option string
opt_str(e.g.,"-q"or"-verbose"). - Returns the Option instance with the option string
opt_str, orNoneif no options have that option string. - If the OptionParser has an option corresponding to
opt_str, that option is removed. If that option provided any other option strings, all of those option strings become invalid.If
opt_strdoes not occur in any option belonging to this OptionParser, raises ValueError.
See About this document... for information on suggesting changes.