parameter files

gry at gry at
Thu Sep 14 03:29:53 CEST 2006

Russ wrote:
> I have a python module (file) that has a set of parameters associated
> with it. Let's say the module is called "" I would like to keep
> the parameter assignments in a separate file so that I can save a copy
> for each "run" without having to save the entire file. Let's
> say the parameter file is called ""
> Normally, would simply import the file. However,
> I don't want the parameters to be accessible to any other file that
> imports the file. to prevent such access, I preface the name of
> each parameter with an underscore. But then the parameters aren't even
> visible in! So I decided to use "execfile" instead of import so
> the parameters are visible.
> That solved the problem, but I am just wondering if there is a better
> and/or more standard way to handle a situation like this. Any
> suggestions? Thanks.

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.

-- George

More information about the Python-list mailing list