On this page
  1. configparser.ConverterMapping
  2. Import
  3. Signature & Overview
  4. Methods & Attributes
  5. Usage
  6. Gotchas
  7. REPL Inspect

configparser.ConverterMapping

Prev: configparser.ConfigParser | Up: configparser | Next: configparser.DuplicateOptionError
Rel: configparser.BasicInterpolation, configparser.ConfigParser, configparser.DuplicateOptionError, configparser.DuplicateSectionError
Ref: docs.python.org — configparser.ConverterMapping
Tags: #public #python3 #stdlib #configparser


Import

import configparser
from configparser import ConverterMapping

Signature & Overview

configparser.ConverterMapping(parser)

Enables reuse of get*() methods between the parser and section proxies.

Methods & Attributes

Usage

import configparser

cp = configparser.ConfigParser(converters={"list": lambda s: [x.strip() for x in s.split(",")]})
cp.read_string("[app]\ntags = a, b, c\n")
assert isinstance(cp.converters, configparser.ConverterMapping)
assert cp["app"].getlist("tags") == ["a", "b", "c"]

Gotchas

REPL Inspect

from configparser import ConverterMapping
help(ConverterMapping)

Linked from

Related notes