On this page
configparser.BasicInterpolation
Up: configparser | Next: configparser.ConfigParser
Rel: configparser.ConfigParser, configparser.ConverterMapping, configparser.DuplicateOptionError, configparser.DuplicateSectionError
Ref: docs.python.org — configparser.BasicInterpolation
Tags: #public #python3 #stdlib #configparser
Import
import configparser
from configparser import BasicInterpolation
Signature & Overview
configparser.BasicInterpolation()
Interpolation as implemented in the classic ConfigParser.
Methods & Attributes
BasicInterpolation.before_get(self, parser, section, option, value, defaults)—BasicInterpolation.before_getmethod/property.BasicInterpolation.before_read(self, parser, section, option, value)—BasicInterpolation.before_readmethod/property.BasicInterpolation.before_set(self, parser, section, option, value)—BasicInterpolation.before_setmethod/property.BasicInterpolation.before_write(self, parser, section, option, value)—BasicInterpolation.before_writemethod/property.
Usage
import configparser
cp = configparser.ConfigParser(interpolation=configparser.BasicInterpolation())
cp.read_string("[paths]\nbase=/opt\nbin=%(base)s/bin\n")
assert cp["paths"]["bin"] == "/opt/bin"
Gotchas
- Default interpolation: Escaping a literal
%requires doubling it (%%), or switch tointerpolation=None.
REPL Inspect
from configparser import BasicInterpolation
help(BasicInterpolation)
Linked from
- tuts/python3/stdlib_module/configparser
- tuts/python3/stdlib_module/configparser/ConfigParser
- tuts/python3/stdlib_module/configparser/ConverterMapping
- tuts/python3/stdlib_module/configparser/DuplicateOptionError
- 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/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/DuplicateOptionError 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