parameter files

Russ uymqlp502 at sneakemail.com
Wed Sep 13 19:26:57 EDT 2006


I have a python module (file) that has a set of parameters associated
with it. Let's say the module is called "code.py." 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 code.py file. Let's
say the parameter file is called "parameters.py."

Normally, code.py would simply import the parameters.py file. However,
I don't want the parameters to be accessible to any other file that
imports the code.py file. to prevent such access, I preface the name of
each parameter with an underscore. But then the parameters aren't even
visible in code.py! 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.




More information about the Python-list mailing list