PyDocs

Nav

File Formats

ConfigParser.get

  • ConfigParser.get(section, option, *, raw=False, vars=None[, fallback])
Get an option value for a given section.

If `vars` is provided, it must be a dictionary. The option is looked up
in `vars` (if provided), `section`, and in `DEFAULTSECT` in that order.
If the key is not found and `fallback` is provided, it is used as
a fallback value. `None` can be provided as a `fallback` value.

If interpolation is enabled and the optional argument `raw` is False,
all interpolations are expanded in the return values.

Arguments `raw`, `vars`, and `fallback` are keyword only.

The section DEFAULT is special.
Changed in 3.2
  • 3.2: Arguments raw, vars and fallback are keyword only to protect users from trying to use the third argument as the fallback fallback (especially when using the mapping protocol).
1 Example
>>> config = """
... option = value
...
... [  Section 2  ]
... another = val
... """
>>> unnamed = configparser.ConfigParser(allow_unnamed_section=True)
>>> unnamed.read_string(config)
>>> unnamed.get(configparser.UNNAMED_SECTION, 'option')
'value'
from the Python docs
See Also
No see-alsos for configparser/ConfigParser.get
0 Notes
No notes for ConfigParser.get