Barak 0.3.2 documentation

barak.io.parse_config

«  barak.io.loadobj   ::   Contents   ::   barak.io.readsex  »

barak.io.parse_config

barak.io.parse_config(filename, defaults={})[source]

Read options for a configuration file.

Parameters :

filename : str or file object

The configuration filename or a file object.

defaults : dict

A dictionary with default values for options.

Returns :

d : dictionary

The options are returned as a dictionary that can also be indexed by attribute.

Notes

Ignores blank lines, lines starting with ‘#’, and anything on a line after a ‘#’. The parser attempts to convert the values to int, float or boolean, otherwise they are left as strings.

Sample format:

# this is the file with the line list
lines = lines.dat
x = 20
save = True    # save the data

«  barak.io.loadobj   ::   Contents   ::   barak.io.readsex  »