On 30. nov. 2011, at 12:09, Giovanni Plantageneto 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? > Thanks. > _______________________________________________ > NumPy-Discussion mailing list > NumPy-Discussion@scipy.org > http://mail.scipy.org/mailman/listinfo/numpy-discussion
I like having my input files simply be python files, on the form bar = 'foo' ham = ['spam', 'eggs'] Then I import them as import imp parameters = imp.load_source("parameters", "myinpufile.py") Now the object 'parameters' is a python module so I can say print parameters.bar and 'foo' will be printed. Paul _______________________________________________ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion