Recommended "new" way for config files
vinay_sajip at yahoo.co.uk
Fri Jan 8 19:50:21 CET 2010
On Jan 7, 8:12 pm, Peter <vm... at mycircuit.org> wrote:
> > <snip>
> >> So what is the "worshipped" approach, when you need more than name=value
> >> pairs ?
> > JSON is one option:http://docs.python.org/library/json.html
> Thanks, didn't think about that, although most of the apps I know don't
> seem to use this approach for improved conf file handling ( ipython,
> pylons, etc ).
> To me , the ipython way ( hybrid: ipy_user_conf.py and *.ini files )
> seems to be the most comprehensive way amongst the larger apps I know
> of, since it let you have a python coded file for what ever you might
> want to do during initialization and have additional .ini files,
> ,possibily several in different locations, for simpler options in
> name,value format.
> Has anybody experiences with other tools that use this approach ?
I don't know if you will find it relevant to your needs, but PEP 391
suggests an alternative method of configuring logging using dicts. The
use of dicts as the basic format (rather than Python code) allows for
some end-user flexibility and interoperability with other systems:
e.g. JSON, YAML and Python can all produce Python dicts.
More information about the Python-list