def parse_config(confstr):
    """
    Use *eval(...)* to execute a filtered AST tree formed by parsing a
    configuration file, removing unwanted expressions (if any) and then
    compiling the filtered output to Python byte code. This approach
    allows the use of Python expressions and comments in config files,
    avoids the use of modules which is not particularily pretty (IMO).

    The following expressions (and combinations of) are allowed:

    Assignments, Arithmetic, Strings, Lists, if...then...else and
    Comments.

    Returns a dict containing the configuration values, if successful. 
    """
    dummy  = dict()
    result = dict()

    # Parse the python source code into a filtered AST-tree.
    cast = _parseconf(confstr)

    # Compile AST to bytecode, this also detects syntax errors.
    cobj = parser.compileast(cast)

    # Run the bytecode. The dicts *dummy* and *results* are placeholders
    # for the *globals* *locals* environments used by *eval(...)*. The
    # variables declared and initialised in the config file will end up
    # in *locals* together with the *__globals__* environment while the
    # *locals* will contain only the values created by *eval(...)*. This
    # is good, because we can protect *__globals__* and return only the
    # configuration values by doing this:
    
    eval(cobj, dummy, result)

    return result

    Use *eval(...)* to execute a filtered AST tree formed by parsing a
    configuration file, removing unwanted expressions (if any) and then
    compiling the filtered output to Python byte code. This approach
    allows the use of Python expressions and comments in config files,
    avoids the use of modules which is not particularily pretty (IMO).

    The following expressions (and combinations of) are allowed:

    Assignments, Arithmetic, Strings, Lists, if...then...else and
    Comments.

    Returns a dict containing the configuration values, if successful. 
    
recipes/Python/576404_Python_config_file_parser/recipe-576404.py