On this page
optparse.OptionConflictError
Prev: optparse.Option | Up: optparse | Next: optparse.OptionContainer
Rel: optparse.BadOptionError, optparse.check_choice, optparse.HelpFormatter, optparse.IndentedHelpFormatter
Ref: docs.python.org โ optparse.OptionConflictError
Tags: #public #python3 #stdlib #optparse
Import
import optparse
from optparse import OptionConflictError
Signature & Overview
optparse.OptionConflictError(msg, option)
Raised if conflicting options are added to an OptionParser.
Methods & Attributes
OptionConflictError.add_note(self, note, /)โ Add a note to the exceptionOptionConflictError.with_traceback(self, tb, /)โ Set self.traceback to tb and return self.
Usage
import optparse
p = optparse.OptionParser()
p.add_option("-v", action="store_true")
try:
p.add_option("-v", action="count")
except optparse.OptionConflictError:
assert True
Gotchas
- Pass
conflict_handler="resolve"toOptionParserif later options should override earlier ones.
REPL Inspect
from optparse import OptionConflictError
help(OptionConflictError)
Linked from
Related notes
- tuts/python3/stdlib_module/optparse/Option Linked here; links to this page; shared tags: #optparse, #stdlib
- tuts/python3/stdlib_module/optparse/OptionContainer Linked here; links to this page; shared tags: #optparse, #stdlib
- tuts/python3/stdlib_module/optparse Linked here; links to this page; shared tags: #stdlib
- tuts/python3/stdlib_module/optparse/BadOptionError Linked here; shared tags: #optparse, #stdlib
- tuts/python3/stdlib_module/optparse/check_choice Linked here; shared tags: #optparse, #stdlib
- tuts/python3/stdlib_module/optparse/HelpFormatter Linked here; shared tags: #optparse, #stdlib
- tuts/python3/stdlib_module/optparse/IndentedHelpFormatter Linked here; shared tags: #optparse, #stdlib
- tuts/python3/stdlib_module/optparse/make_option shared tags: #optparse, #stdlib
- tuts/python3/stdlib_module/optparse/OptionError shared tags: #optparse, #stdlib
- tuts/python3/stdlib_module/optparse/OptionGroup shared tags: #optparse, #stdlib