On this page
configparser.ExtendedInterpolation
Prev: configparser.DuplicateSectionError | Up: configparser | Next: configparser.Interpolation
Rel: configparser.BasicInterpolation, configparser.ConfigParser, configparser.ConverterMapping, configparser.DuplicateOptionError
Ref: docs.python.org — configparser.ExtendedInterpolation
Tags: #public #python3 #stdlib #configparser
Import
import configparser
from configparser import ExtendedInterpolation
Signature & Overview
configparser.ExtendedInterpolation()
Advanced variant of interpolation, supports the syntax used by zc.buildout. Enables interpolation between sections.
Methods & Attributes
ExtendedInterpolation.before_get(self, parser, section, option, value, defaults)—ExtendedInterpolation.before_getmethod/property.ExtendedInterpolation.before_read(self, parser, section, option, value)—ExtendedInterpolation.before_readmethod/property.ExtendedInterpolation.before_set(self, parser, section, option, value)—ExtendedInterpolation.before_setmethod/property.ExtendedInterpolation.before_write(self, parser, section, option, value)—ExtendedInterpolation.before_writemethod/property.
Usage
import configparser
cp = configparser.ConfigParser(interpolation=configparser.ExtendedInterpolation())
cp.read_string("[common]\nroot=/srv\n[app]\ndata=${common:root}/data\n")
assert cp["app"]["data"] == "/srv/data"
Gotchas
- Supports cross-section
${section:option}references: Escape literal$as$$.
REPL Inspect
from configparser import ExtendedInterpolation
help(ExtendedInterpolation)
Linked from
Related notes
- tuts/python3/stdlib_module/configparser/DuplicateSectionError Linked here; links to this page; shared tags: #configparser, #stdlib
- tuts/python3/stdlib_module/configparser/Interpolation 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/InterpolationDepthError shared tags: #configparser, #stdlib
- tuts/python3/stdlib_module/configparser/InterpolationError shared tags: #configparser, #stdlib
- tuts/python3/stdlib_module/configparser/InterpolationMissingOptionError shared tags: #configparser, #stdlib