parameter files

Gabriel Genellina gagsl-py at
Thu Sep 14 06:31:49 CEST 2006

At Thursday 14/9/2006 01:10, Russ wrote:

> > I would try a configuration file, instead of a python module.
> > See ConfigParser:
> > <>.
> > You can save values for each "run" in a separate [section].
> > Execfile is a pretty big hammer for this.
>Hey, that looks interesting, but those docs don't do it for me. Can you
>point me to some more extensive examples of how to use ConfigParser?

Just forget about interpolation and such; declare a section for each 
run in your config file:



config = ConfigParser.ConfigParser()
a = config.getint('run_two','a') # a==456
b = config.get('run_name_one','b') # b=='Test'
section = 'run_two'
c = config.getfloat(section,'c') # c==0.1

Gabriel Genellina
Softlab SRL 

Preguntá. Respondé. Descubrí.
Todo lo que querías saber, y lo que ni imaginabas,
está en Yahoo! Respuestas (Beta).
¡Probalo ya!

More information about the Python-list mailing list