Recommended "new" way for config files

Peter vmail at mycircuit.org
Thu Jan 7 13:19:40 EST 2010


Thanks for your answer, let me be more precise:

> I would add the standard module ConfigParser 
> http://docs.python.org/library/configparser.html to your list.
of course, that was the implicit starting point of my request, when 
talking about .ini files.
> I don't know exactly what you intend to do with point 4/, 
It would allow me to select different conf.py files with command line 
switches, like for example a  -c <alternative conf file> option.
> 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.
>
Would this be considered a hack ?

#!/usr/bin/env python

import sys

# parse command line options here

if option='standard':
   const = __import__('consts')
else:
   const = __import__('alternative_consts')

> The .ini file is the simpliest solution, at least from the user point 
> of view, no need to learn any python syntax.
I am speaking from the point of view of a python programmer, and I find 
the .ini restrictions not necessarily simple, for example when dealing 
with structured data (I suppose it is trivial to specify a dictionnary 
or a list for the purpose of my request) For example, configuration 
files for the logging module get unwieldy when you specify several 
loggers , handlers, formatters etc, because you have to break down 
structured data ( objects ) to name,value pairs.
> However, speeking for myself, I am using python coded configuration 
> files, but: we all worship python in the team and thus are familiar 
> with it.
>
so do I.
> JM
>
>
So what is the "worshipped" approach, when you need more than name=value 
pairs ?

Peter







More information about the Python-list mailing list