.ini configuration files from Python 1.1 Jos´ e Fonseca 1.1.1 University of the Western Cape 1.1.2 5th Oct 2017 @PyConZA 1.1.3 slack zefonseca In [1]: #What I need to import import os from configobj import ConfigObj import numpy as np import matplotlib.pyplot as plt %matplotlib inline As a cosmologist I use CAMB sources - a code written in fortran - to make my Fisher Forecasts (fancy name to access performance of experiments). But that means I need to run the code with one sligth change dozens of hundreds of times. By hand it can be a mission. So really nice that configobj exists (and os as well). configobj is a parser that imports the configuration file and transforms all id=something from the configuration file into a dictionary with id as keys and something as ‘value’. In [2]: ### Example original=’template.ini’ filename=’PyConZA_example.ini’ os.system(’cp ’+original+’ ’+filename) inifile=ConfigObj(filename) In [3]: inifile.keys() Out[3]: [’output root’, ’get scalar cls’, ’get vector cls’, ’get tensor cls’, ’get transfer’, ’do lensing’, ’do nonlinear’, ’l max scalar’, ’l max tensor’, ’k eta max tensor’, ’use physical’, ’hubble’, 1