Recommended "new" way for config files

Jean-Michel Pichavant jeanmichel at
Thu Jan 7 17:32:32 CET 2010

Peter wrote:
> Hi
> There seems to be several strategies to enhance the old ini-style 
> config files with real python code, for example:
> 1) the documentation tool sphinx uses a python file that is 
> exefile(d) , but execfile is suppressed in Python 3
> 2) there is a module cfgparse on sourceforge that supports a hybrid style
> 3) modern tools like ipython seems to favor a new style based on 
> python code config files but also support a hybrid style mixing .ini 
> files and python code files.
> 4) I could use __import__ to import modules based on some command line 
> options
> Is there a strategy that should be prefered for new projects ?
> thanks
> peter
I would add the standard module ConfigParser to your list.
I don't know exactly what you intend to do with point 4/, but I would 
exclude it if any other point may fit. Imports can become tricky when 
used out of the common way. Anyway, hacking the import statement for 
managing configuration files does not sound very appropriate.

The .ini file is the simpliest solution, at least from the user point of 
view, no need to learn any python syntax.
However, speeking for myself, I am using python coded configuration 
files, but: we all worship python in the team and thus are familiar with 


More information about the Python-list mailing list