pydoc > configparser

📋 NAME

configparser — Configuration file parser.

🚀 Quick Reference

Use CaseCommandDescription
📝 Create a parserconfig = configparser.ConfigParser()Instantiate a new config parser with default settings
📂 Read a fileconfig.read('config.ini')Parse a configuration file (silently ignores missing files)
📄 Read from stringconfig.read_string(string)Parse configuration from a string
🔍 Get a valueconfig.get('section', 'key')Retrieve a string value for an option
🔢 Get with type conversionconfig.getint('section', 'key')Retrieve an integer value
✏️ Set a valueconfig.set('section', 'key', 'value')Set an option in a section
💾 Write to fileconfig.write(file)Write configuration in .ini format
🗂️ List sectionsconfig.sections()Return all section names (excluding DEFAULT)
❓ Check option existenceconfig.has_option('section', 'key')Check if a specific option exists

📚 DESCRIPTION

A configuration file consists of sections, lead by a [section] header, and followed by name: value entries, with continuations and such in the style of RFC 822.

Intrinsic defaults can be specified by passing them into the ConfigParser constructor as a dictionary.

🔗 MODULE REFERENCE

https://docs.python.org/3.10/library/configparser.html

The following documentation is automatically generated from the Python source files. It may be incomplete, incorrect or include features that are considered implementation detail and may vary between Python implementations. When in doubt, consult the module reference at the location listed above.

📦 CLASSES

🗂️ Interpolation

Dummy interpolation that passes the value through with no changes.

Method resolution order: Interpolation, builtins.object

Data descriptors: __dict__, __weakref__

🗂️ BasicInterpolation

Interpolation as implemented in the classic ConfigParser.

Method resolution order: BasicInterpolation, Interpolation, builtins.object

Inherited from Interpolation: before_read, before_write, __dict__, __weakref__

🗂️ ExtendedInterpolation

Advanced variant of interpolation supporting zc.buildout syntax. Enables interpolation between sections.

Method resolution order: ExtendedInterpolation, Interpolation, builtins.object

Inherited from Interpolation: before_read, before_write, __dict__, __weakref__

🗂️ LegacyInterpolation

Deprecated interpolation used in old versions of ConfigParser. Use BasicInterpolation or ExtendedInterpolation instead.

Method resolution order: LegacyInterpolation, Interpolation, builtins.object

Inherited from Interpolation: before_read, before_write, __dict__, __weakref__

🗂️ Error

Base class for configparser exceptions.

Method resolution order: Error, builtins.Exception, builtins.BaseException, builtins.object

Data descriptor: __weakref__

Inherited from builtins.Exception: __new__

Inherited from builtins.BaseException: __delattr__, __getattribute__, __reduce__, __setattr__, __setstate__, with_traceback, __cause__, __context__, __dict__, __suppress_context__, __traceback__, args

🗂️ DuplicateOptionError

Raised by strict parsers when an option is repeated in an input source.

Method resolution order: DuplicateOptionError, Error, builtins.Exception, builtins.BaseException, builtins.object

Inherited from Error: __repr__, __str__, __weakref__

Inherited from builtins.Exception: __new__

Inherited from builtins.BaseException: __delattr__, __getattribute__, __reduce__, __setattr__, __setstate__, with_traceback, __cause__, __context__, __dict__, __suppress_context__, __traceback__, args

🗂️ DuplicateSectionError

Raised when a section is repeated in an input source.

Method resolution order: DuplicateSectionError, Error, builtins.Exception, builtins.BaseException, builtins.object

Inherited from Error: __repr__, __str__, __weakref__

Inherited from builtins.Exception: __new__

Inherited from builtins.BaseException: __delattr__, __getattribute__, __reduce__, __setattr__, __setstate__, with_traceback, __cause__, __context__, __dict__, __suppress_context__, __traceback__, args

🗂️ InterpolationError

Base class for interpolation-related exceptions.

Method resolution order: InterpolationError, Error, builtins.Exception, builtins.BaseException, builtins.object

Inherited from Error: __repr__, __str__, __weakref__

Inherited from builtins.Exception: __new__

Inherited from builtins.BaseException: __delattr__, __getattribute__, __reduce__, __setattr__, __setstate__, with_traceback, __cause__, __context__, __dict__, __suppress_context__, __traceback__, args

🗂️ InterpolationDepthError

Raised when substitutions are nested too deeply.

Method resolution order: InterpolationDepthError, InterpolationError, Error, builtins.Exception, builtins.BaseException, builtins.object

Inherited from InterpolationError: __init__ (overridden)

Inherited from Error: __repr__, __str__, __weakref__

Inherited from builtins.Exception: __new__

Inherited from builtins.BaseException: __delattr__, __getattribute__, __reduce__, __setattr__, __setstate__, with_traceback, __cause__, __context__, __dict__, __suppress_context__, __traceback__, args

🗂️ InterpolationMissingOptionError

A string substitution required a setting which was not available.

Method resolution order: InterpolationMissingOptionError, InterpolationError, Error, builtins.Exception, builtins.BaseException, builtins.object

Inherited from InterpolationError: __init__ (overridden)

Inherited from Error: __repr__, __str__, __weakref__

Inherited from builtins.Exception: __new__

Inherited from builtins.BaseException: __delattr__, __getattribute__, __reduce__, __setattr__, __setstate__, with_traceback, __cause__, __context__, __dict__, __suppress_context__, __traceback__, args

🗂️ InterpolationSyntaxError

Raised when the source text contains invalid syntax.

Method resolution order: InterpolationSyntaxError, InterpolationError, Error, builtins.Exception, builtins.BaseException, builtins.object

Methods inherited from InterpolationError: __init__

Inherited from Error: __repr__, __str__, __weakref__

Inherited from builtins.Exception: __new__

Inherited from builtins.BaseException: __delattr__, __getattribute__, __reduce__, __setattr__, __setstate__, with_traceback, __cause__, __context__, __dict__, __suppress_context__, __traceback__, args

🗂️ NoOptionError

A requested option was not found.

Method resolution order: NoOptionError, Error, builtins.Exception, builtins.BaseException, builtins.object

Inherited from Error: __repr__, __str__, __weakref__

Inherited from builtins.Exception: __new__

Inherited from builtins.BaseException: __delattr__, __getattribute__, __reduce__, __setattr__, __setstate__, with_traceback, __cause__, __context__, __dict__, __suppress_context__, __traceback__, args

🗂️ NoSectionError

Raised when no section matches a requested option.

Method resolution order: NoSectionError, Error, builtins.Exception, builtins.BaseException, builtins.object

Inherited from Error: __repr__, __str__, __weakref__

Inherited from builtins.Exception: __new__

Inherited from builtins.BaseException: __delattr__, __getattribute__, __reduce__, __setattr__, __setstate__, with_traceback, __cause__, __context__, __dict__, __suppress_context__, __traceback__, args

🗂️ ParsingError

Raised when a configuration file does not follow legal syntax.

Method resolution order: ParsingError, Error, builtins.Exception, builtins.BaseException, builtins.object

Data descriptor: filename (deprecated, use source)

Inherited from Error: __repr__, __str__, __weakref__

Inherited from builtins.Exception: __new__

Inherited from builtins.BaseException: __delattr__, __getattribute__, __reduce__, __setattr__, __setstate__, with_traceback, __cause__, __context__, __dict__, __suppress_context__, __traceback__, args

🗂️ MissingSectionHeaderError

Raised when a key-value pair is found before any section header.

Method resolution order: MissingSectionHeaderError, ParsingError, Error, builtins.Exception, builtins.BaseException, builtins.object

Inherited from ParsingError: append, filename

Inherited from Error: __repr__, __str__, __weakref__

Inherited from builtins.Exception: __new__

Inherited from builtins.BaseException: __delattr__, __getattribute__, __reduce__, __setattr__, __setstate__, with_traceback, __cause__, __context__, __dict__, __suppress_context__, __traceback__, args

🗂️ RawConfigParser

ConfigParser that does not do interpolation.

Constructor: RawConfigParser(defaults=None, dict_type=<class 'dict'>, allow_no_value=False, *, delimiters=('=', ':'), comment_prefixes=('#', ';'), inline_comment_prefixes=None, strict=True, empty_lines_in_values=True, default_section='DEFAULT', interpolation=<unset>, converters=<unset>)

Method resolution order: RawConfigParser, collections.abc.MutableMapping, collections.abc.Mapping, collections.abc.Collection, collections.abc.Sized, collections.abc.Iterable, collections.abc.Container, builtins.object

Readonly properties: converters

Data descriptors: __dict__, __weakref__

Class attributes: BOOLEAN_STATES = {'0': False, '1': True, 'false': False, 'no': False, ...}, NONSPACECRE, OPTCRE, OPTCRE_NV, SECTCRE, __abstractmethods__

Inherited from collections.abc.MutableMapping: clear, pop, setdefault, update

Inherited from collections.abc.Mapping: __eq__, keys, values, __hash__ = None, __reversed__ = None

Inherited from collections.abc.Collection: __subclasshook__

Inherited from collections.abc.Iterable: __class_getitem__

🗂️ ConfigParser

ConfigParser implementing interpolation.

Constructor: ConfigParser(defaults=None, dict_type=<class 'dict'>, allow_no_value=False, *, delimiters=('=', ':'), comment_prefixes=('#', ';'), inline_comment_prefixes=None, strict=True, empty_lines_in_values=True, default_section='DEFAULT', interpolation=<object object>, converters=<object object>)

Method resolution order: ConfigParser, RawConfigParser, collections.abc.MutableMapping, collections.abc.Mapping, collections.abc.Collection, collections.abc.Sized, collections.abc.Iterable, collections.abc.Container, builtins.object

Methods defined here:

Data attributes: __abstractmethods__ = frozenset()

All other methods inherited from RawConfigParser.

🗂️ SafeConfigParser

ConfigParser alias for backwards compatibility purposes.

Constructor: SafeConfigParser(*args, **kwargs)

Method resolution order: SafeConfigParser, ConfigParser, RawConfigParser, collections.abc.MutableMapping, collections.abc.Mapping, collections.abc.Collection, collections.abc.Sized, collections.abc.Iterable, collections.abc.Container, builtins.object

Methods defined here:

Data attributes: __abstractmethods__ = frozenset()

All other methods inherited from ConfigParser and RawConfigParser.

🗂️ SectionProxy

A proxy for a single section from a parser.

Constructor: SectionProxy(parser, name) — Creates a view on a section of the specified name in parser.

Method resolution order: SectionProxy, collections.abc.MutableMapping, collections.abc.Mapping, collections.abc.Collection, collections.abc.Sized, collections.abc.Iterable, collections.abc.Container, builtins.object

Readonly properties: name, parser

Data descriptors: __dict__, __weakref__

Data attributes: __abstractmethods__ = frozenset()

Inherited from collections.abc.MutableMapping: clear, pop, popitem, setdefault, update

Inherited from collections.abc.Mapping: __eq__, items, keys, values, __hash__ = None, __reversed__ = None

Inherited from collections.abc.Collection: __subclasshook__

Inherited from collections.abc.Iterable: __class_getitem__

🗂️ ConverterMapping

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

Constructor: ConverterMapping(parser)

Method resolution order: ConverterMapping, collections.abc.MutableMapping, collections.abc.Mapping, collections.abc.Collection, collections.abc.Sized, collections.abc.Iterable, collections.abc.Container, builtins.object

Data descriptors: __dict__, __weakref__

Data attributes: GETTERCRE = re.compile('^get(?P<name>.+)$'), __abstractmethods__ = frozenset()

Inherited from collections.abc.MutableMapping: clear, pop, popitem, setdefault, update

Inherited from collections.abc.Mapping: __contains__, __eq__, get, items, keys, values, __hash__ = None, __reversed__ = None

Inherited from collections.abc.Collection: __subclasshook__

Inherited from collections.abc.Iterable: __class_getitem__

📊 DATA

📁 FILE

/usr/lib/python3.10/configparser.py

configparser
📋 NAME 🚀 Quick Reference 📚 DESCRIPTION 🔗 MODULE REFERENCE 📦 CLASSES
🗂️ Interpolation 🗂️ BasicInterpolation 🗂️ ExtendedInterpolation 🗂️ LegacyInterpolation 🗂️ Error 🗂️ DuplicateOptionError 🗂️ DuplicateSectionError 🗂️ InterpolationError 🗂️ InterpolationDepthError 🗂️ InterpolationMissingOptionError 🗂️ InterpolationSyntaxError 🗂️ NoOptionError 🗂️ NoSectionError 🗂️ ParsingError 🗂️ MissingSectionHeaderError 🗂️ RawConfigParser 🗂️ ConfigParser 🗂️ SafeConfigParser 🗂️ SectionProxy 🗂️ ConverterMapping
📊 DATA 📁 FILE

Generated by phpman v4.10.0-7-g98e9fd5 · Markdown · JSON · MCP Author: Che Dong Under GNU General Public License
2026-09-01 16:48 @216.73.216.239
CrawledBy Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)
Valid XHTML 1.0 Transitional!Valid CSS!

^_top_^