On this page
configparser.NoOptionError
Prev: configparser.MultilineContinuationError | Up: configparser | Next: configparser.NoSectionError
Rel: configparser.BasicInterpolation, configparser.ConfigParser, configparser.ConverterMapping, configparser.DuplicateOptionError
Ref: docs.python.org โ configparser.NoOptionError
Tags: #public #python3 #stdlib #configparser
Import
import configparser
from configparser import NoOptionError
Signature & Overview
configparser.NoOptionError(option, section)
A requested option was not found.
Methods & Attributes
NoOptionError.add_note(self, note, /)โ Add a note to the exceptionNoOptionError.with_traceback(self, tb, /)โ Set self.traceback to tb and return self.
Usage
import configparser
cp = configparser.ConfigParser()
cp.read_string("[s]\na = 1\n")
try:
cp.get("s", "missing")
except configparser.NoOptionError:
assert True
Gotchas
- Pass
fallback=to avoid catchingNoOptionError:cp.get("s", "missing", fallback="default").
REPL Inspect
from configparser import NoOptionError
help(NoOptionError)
Linked from
Related notes
- tuts/python3/stdlib_module/configparser/MultilineContinuationError Linked here; links to this page; shared tags: #configparser, #stdlib
- tuts/python3/stdlib_module/configparser/NoSectionError Linked here; links to this page; shared tags: #configparser, #stdlib
- tuts/python3/stdlib_module/configparser/BasicInterpolation Linked here; shared tags: #configparser, #stdlib
- tuts/python3/stdlib_module/configparser/ConfigParser Linked here; shared tags: #configparser, #stdlib
- tuts/python3/stdlib_module/configparser/ConverterMapping Linked here; shared tags: #configparser, #stdlib
- tuts/python3/stdlib_module/configparser/DuplicateOptionError Linked here; shared tags: #configparser, #stdlib
- tuts/python3/stdlib_module/configparser links to this page; shared tags: #stdlib
- tuts/python3/stdlib_module/configparser/DuplicateSectionError shared tags: #configparser, #stdlib
- tuts/python3/stdlib_module/configparser/ExtendedInterpolation shared tags: #configparser, #stdlib
- tuts/python3/stdlib_module/configparser/Interpolation shared tags: #configparser, #stdlib