From: Chris Rebert on
On Thu, Jan 7, 2010 at 10:19 AM, Peter <vmail(a)mycircuit.org> wrote:
<snip>
>> 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.
<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

Cheers,
Chris
--
http://blog.rebertia.com
From: Peter on

> <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 ?

Peter
From: Jorgen Grahn on
On Thu, 2010-01-07, Jean-Michel Pichavant wrote:
> Peter wrote:
>> Hi
>> There seems to be several strategies to enhance the old ini-style
>> config files with real python code, for example:
....
>> Is there a strategy that should be prefered for new projects ?

....
> The .ini file is the simpliest solution, at least from the user point of
> view, no need to learn any python syntax.

Yeah. Use whatever your users expect, and deal with it. The language
you've happened to implement your stuff in should normally be
irrelevant to the users.

I wouldn't use .ini-style, but that's because I'm a Unix guy and they
remind me of brief and painful experiments with Windows 3.1.

Just remember to include support for commented-out lines.

/Jorgen

--
// Jorgen Grahn <grahn@ Oo o. . .
\X/ snipabacken.se> O o .
From: r0g on
Chris Rebert wrote:
> On Thu, Jan 7, 2010 at 10:19 AM, Peter <vmail(a)mycircuit.org> wrote:
> <snip>
>>> 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.
> <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
>
> Cheers,
> Chris
> --
> http://blog.rebertia.com


Yes, JSON is rapidly becoming a standard for stuff like this as it's
widely portable and less bulky than XML. It's the native format for
couchdb too which is nice if you want to replicate and share the
contents of your documents.

Roger.
From: Vinay Sajip on
On Jan 7, 8:12 pm, Peter <vm...(a)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 ?
>
> Peter

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.

Regards,

Vinay Sajip