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

Benjamin Root ben.root@ou....
Wed Nov 30 09:11:05 CST 2011


On Wednesday, November 30, 2011, Robert Kern <robert.kern@gmail.com> wrote:
> On Wed, Nov 30, 2011 at 11:09, Giovanni Plantageneto
> <g.plantageneto@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@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.

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


More information about the NumPy-Discussion mailing list