Why shouldn't you put config options in py files

rdmurray at bitdance.com rdmurray at bitdance.com
Thu Dec 4 21:22:19 CET 2008

On Thu, 4 Dec 2008 at 11:35, HT wrote:
> I can think of lots of arguments why this is a bad idea, but I don't
> seem to be able to think of a really convincing one.

I think it depends on the problem domain.  As someone else said, there
are issues with being able to inject arbitrary code via the config file.
In some applications, this would be a feature, in others it would be a
security hole.

Another angle to look at is the audience for the config file.  If they
are all going to be python programmers or python-familiar, great.
If not...think about the user reaction to the tracebacks resulting from
typos.  If you use a purpose-designed config file (whether it is based on
ConfigParser or not), you can more easily generate helpful error messages.


More information about the Python-list mailing list