pythonic way of making a config module

Fuzzyman fuzzyman at gmail.com
Wed Jan 18 11:04:30 EST 2006


andrew.fab... at gmail.com wrote:
> I'm working on an app that will be deployed on several different
> servers.  In each case, I'll want to change some config info (database
> name, paths, etc.)
>
> In perl, I would have done something like this:
>
>   Package Config;
>   <some exporting mechanics>
>   $dbname = "somename";
>   etc.
>

Create a python module that defines the variables you want, and then
import it (or from it).

You can then edit that module as a config file.

That's one suggestion - with the security risks associated with an
import statement...

Alternatively, my usual reccomendation for a config file reader is
ConfigObj... ;-)

All the best,

Fuzzyman
http://www.voidspace.org.uk/python/index.shtml




More information about the Python-list mailing list