On this page
configparser.RawConfigParser
Prev: configparser.ParsingError | Up: configparser | Next: configparser.SectionProxy
Rel: configparser.BasicInterpolation, configparser.ConfigParser, configparser.ConverterMapping, configparser.DuplicateOptionError
Ref: docs.python.org — configparser.RawConfigParser
Tags: #public #python3 #stdlib #configparser
Import
import configparser
from configparser import RawConfigParser
Signature & Overview
configparser.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=<object object at 0x1040b4c80>, converters=<object object at 0x1040b4c80>, allow_unnamed_section=False)
ConfigParser that does not do interpolation.
Methods & Attributes
RawConfigParser.add_section(self, section)— Create a new section in the configuration.RawConfigParser.clear(self)— D.clear() -> None. Remove all items from D.RawConfigParser.converters(...)—RawConfigParser.convertersmethod/property.RawConfigParser.defaults(self)—RawConfigParser.defaultsmethod/property.RawConfigParser.get(self, section, option, *, raw=False, vars=None, fallback=<object object at 0x1040b4c80>)— Get an option value for a given section.RawConfigParser.getboolean(self, section, option, *, raw=False, vars=None, fallback=<object object at 0x1040b4c80>, **kwargs)—RawConfigParser.getbooleanmethod/property.RawConfigParser.getfloat(self, section, option, *, raw=False, vars=None, fallback=<object object at 0x1040b4c80>, **kwargs)—RawConfigParser.getfloatmethod/property.RawConfigParser.getint(self, section, option, *, raw=False, vars=None, fallback=<object object at 0x1040b4c80>, **kwargs)—RawConfigParser.getintmethod/property.RawConfigParser.has_option(self, section, option)— Check for the existence of a given option in a given section.RawConfigParser.has_section(self, section)— Indicate whether the named section is present in the configuration.RawConfigParser.items(self, section=<object object at 0x1040b4c80>, raw=False, vars=None)— Return a list of (name, value) tuples for each option in a section.RawConfigParser.keys(self)— D.keys() -> a set-like object providing a view on D's keysRawConfigParser.options(self, section)— Return a list of option names for the given section name.RawConfigParser.optionxform(self, optionstr)—RawConfigParser.optionxformmethod/property.RawConfigParser.pop(self, key, default=<object object at 0x1040b41c0>)— value. If key is not found, d is returned if given, otherwise KeyError is raised.RawConfigParser.popitem(self)— Remove a section from the parser and return it as a (section_name, section_proxy) tuple. If no section is present, raise KeyError.RawConfigParser.read(self, filenames, encoding=None)— Read and parse a filename or an iterable of filenames.RawConfigParser.read_dict(self, dictionary, source='<dict>')— Read configuration from a dictionary.RawConfigParser.read_file(self, f, source=None)— Like read() but the argument must be a file-like object.RawConfigParser.read_string(self, string, source='<string>')— Read configuration from a given string.RawConfigParser.remove_option(self, section, option)— Remove an option.RawConfigParser.remove_section(self, section)— Remove a file section.RawConfigParser.sections(self)— Return a list of section names, excluding [DEFAULT]RawConfigParser.set(self, section, option, value=None)— Set an option.RawConfigParser.setdefault(self, key, default=None)— D.setdefault(k[,d]) -> D.get(k,d), also set D[k]=d if k not in DRawConfigParser.update(self, other=(), /, **kwds)— If E present and has a .keys() method, does: for k in E.keys(): D[k] = E[k] If E present and lacks .keys() method, does:RawConfigParser.values(self)— D.values() -> an object providing a view on D's valuesRawConfigParser.write(self, fp, space_around_delimiters=True)— Write an .ini-format representation of the configuration state.
Usage
import configparser
cp = configparser.RawConfigParser()
cp.read_string("[s]\nfmt = 100% raw\n")
assert cp["s"]["fmt"] == "100% raw"
Gotchas
- Legacy variant with
interpolation=None: Modern code can useConfigParser(interpolation=None)directly.
REPL Inspect
from configparser import RawConfigParser
help(RawConfigParser)
Linked from
Related notes
- tuts/python3/stdlib_module/configparser/ParsingError Linked here; links to this page; shared tags: #configparser, #stdlib
- tuts/python3/stdlib_module/configparser/SectionProxy 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