[Numpy-discussion] Reading automatically all the parameters from a file

Benjamin Root ben.root at ou.edu
Wed Nov 30 10:11:05 EST 2011

On Wednesday, November 30, 2011, Robert Kern <robert.kern at gmail.com> wrote:
> On Wed, Nov 30, 2011 at 11:09, Giovanni Plantageneto
> <g.plantageneto at gmail.com> wrote:
>> Dear all,
>> I have a simple question. I would like to have all the parameters of a
>> model written in a configuration file (text), and I would like to have
>> all the parameters in the file automatically defined inside a program.
>> I find ConfigParser a bit low level, is there any function that
>> automatically reads everything from a file?
> You may want to give something like configobj a try.
>  http://pypi.python.org/pypi/configobj
> It builds on ConfigParser to read all of the parameters in and creates
> a hierarchical object will all of the parameters as attributes.
> --
> Robert Kern
> "I have come to believe that the whole world is an enigma, a harmless
> enigma that is made terrible by our own mad attempt to interpret it as
> though it had an underlying truth."
>   -- Umberto Eco
> _______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion at scipy.org
> http://mail.scipy.org/mailman/listinfo/numpy-discussion

+1 on configobj.  I use this module extensively for my simulation
configuration.  It can even do some validation of parameters and allows for
saving of comments.  Furthermore, it utilizes the dictionary idiom, which
makes it very easy to work with, especially for passing kwargs to functions.

Ben Root
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20111130/5d36389a/attachment.html>

More information about the NumPy-Discussion mailing list