On this page
configparser.DuplicateOptionError
Prev: configparser.ConverterMapping | Up: configparser | Next: configparser.DuplicateSectionError
Rel: configparser.BasicInterpolation, configparser.ConfigParser, configparser.ConverterMapping, configparser.DuplicateSectionError
Ref: docs.python.org โ configparser.DuplicateOptionError
Tags: #public #python3 #stdlib #configparser
Import
import configparser
from configparser import DuplicateOptionError
Signature & Overview
configparser.DuplicateOptionError(section, option, source=None, lineno=None)
Raised by strict parsers when an option is repeated in an input source.
Methods & Attributes
DuplicateOptionError.add_note(self, note, /)โ Add a note to the exceptionDuplicateOptionError.with_traceback(self, tb, /)โ Set self.traceback to tb and return self.
Usage
import configparser
cp = configparser.ConfigParser(strict=True)
try:
cp.read_string("[s]\na = 1\na = 2\n")
except configparser.DuplicateOptionError:
assert True
Gotchas
- Raised when
strict=True(the default): Passstrict=Falseto let later keys overwrite earlier ones.
REPL Inspect
from configparser import DuplicateOptionError
help(DuplicateOptionError)
Linked from
- tuts/python3/stdlib_module/configparser
- tuts/python3/stdlib_module/configparser/BasicInterpolation
- tuts/python3/stdlib_module/configparser/ConfigParser
- tuts/python3/stdlib_module/configparser/ConverterMapping
- tuts/python3/stdlib_module/configparser/DuplicateSectionError
- tuts/python3/stdlib_module/configparser/ExtendedInterpolation
- tuts/python3/stdlib_module/configparser/Interpolation
- tuts/python3/stdlib_module/configparser/InterpolationDepthError
- tuts/python3/stdlib_module/configparser/InterpolationError
- tuts/python3/stdlib_module/configparser/InterpolationMissingOptionError
- tuts/python3/stdlib_module/configparser/InterpolationSyntaxError
- tuts/python3/stdlib_module/configparser/InvalidWriteError
- tuts/python3/stdlib_module/configparser/MissingSectionHeaderError
- tuts/python3/stdlib_module/configparser/MultilineContinuationError
- tuts/python3/stdlib_module/configparser/NoOptionError
- tuts/python3/stdlib_module/configparser/NoSectionError
- tuts/python3/stdlib_module/configparser/ParsingError
- tuts/python3/stdlib_module/configparser/RawConfigParser
- tuts/python3/stdlib_module/configparser/SectionProxy
- tuts/python3/stdlib_module/configparser/UnnamedSectionDisabledError
Related notes
- tuts/python3/stdlib_module/configparser/BasicInterpolation Linked here; links to this page; shared tags: #configparser, #stdlib
- tuts/python3/stdlib_module/configparser/ConfigParser Linked here; links to this page; shared tags: #configparser, #stdlib
- tuts/python3/stdlib_module/configparser/ConverterMapping Linked here; links to this page; shared tags: #configparser, #stdlib
- tuts/python3/stdlib_module/configparser/DuplicateSectionError Linked here; links to this page; shared tags: #configparser, #stdlib
- tuts/python3/stdlib_module/configparser/ExtendedInterpolation links to this page; shared tags: #configparser, #stdlib
- tuts/python3/stdlib_module/configparser/Interpolation links to this page; shared tags: #configparser, #stdlib
- tuts/python3/stdlib_module/configparser/InterpolationDepthError links to this page; shared tags: #configparser, #stdlib
- tuts/python3/stdlib_module/configparser/InterpolationError links to this page; shared tags: #configparser, #stdlib
- tuts/python3/stdlib_module/configparser/InterpolationMissingOptionError links to this page; shared tags: #configparser, #stdlib
- tuts/python3/stdlib_module/configparser/InterpolationSyntaxError links to this page; shared tags: #configparser, #stdlib