get_ini.MyConfigParser

class get_ini.MyConfigParser(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>)[source]

Enhanced ConfigParser with automatic type inference.

This class extends the standard ConfigParser to automatically convert string values to appropriate Python types using ast.literal_eval. It safely handles both simple types (int, float, bool) and complex types (lists, dicts, tuples).

The conversion is attempted using ast.literal_eval, which safely evaluates strings containing Python literals. If conversion fails, the original string value is returned unchanged.

get(section, option, *, raw=False, vars=None, fallback=<object object>)[source]

Get an option value with automatic type conversion.

This method extends the standard ConfigParser.get() by attempting to convert string values to appropriate Python types.

Parameters:
  • section (str) – Section name in the configuration

  • option (str) – Option name in the specified section

  • raw (bool, optional) – If True, no interpolation is performed

  • vars (dict, optional) – Dictionary of substitution variables

  • fallback (any, optional) – Value to return if the option is not found

Returns:

The option value converted to its appropriate Python type, or the original string if conversion fails

Return type:

any