[Python-Dev] ConfigParser patches

François Pinard pinard at iro.umontreal.ca
Sat Oct 2 02:43:54 CEST 2004

[Guido van Rossum]

> The outrageous verbosity of XML makes the above example a complete
> usability liability. [...] I'm talking about the classic configuration
> file pattern where you use your favorite flat-file text editor to edit
> the options file.  In that situation, using XML is insane.

XML may sometimes be useful _when_ a configuration _has_ to be a tree of
thick (contents heavy) nodes.  For simpler configurations files, and this
covers a flurry of cases, Guido above expresses my feelings exactly.

There are XML-fanatics -- the same as there are Unicode-fanatics :-).
Not so long ago, I've seen a pushy trend by which `/etc/passwd' and a
lot of other simple system files would be reformulated as XML, to be XML
all over.  (Maybe after an announcement of Microsoft -- real or made-up,
I do not know -- that they aim such a thing for the next "Windows".)

We should not go overboard with XML.  Configuration files with lines and
words for structuring of a two-level hierarchy have long proven their
value.  ConfigParser `.ini' files add a third level to these. and with
good sense, we can still go another long way without resorting to XML.

Besides, when configuration files are going to have some more complex
structure, but explicitly made to drive big applications written in
Python -- a common case for most of us presumably -- I found out that
Python itself is a very convenient and powerful tool for expressing
such parameterisation.  Users can easily modify a carefully designed
Python-written configuration template without knowing a bit about
Python itself.  If they know the concepts of the applications they are
configuring, in my experience at least, they quickly get what needs to
be done, and even grasp by mere mimetism, without much explanations,
the bits of syntax to respect and follow.  With proper care, this can
be made incredibly powerful, while staying _way_ more legible than XML.
Also compare speed and simplicity, for the application programmer, for
bringing such configuration in memory, type concerns already addressed.

Of course, XML better inter-operates with foreign programming languages
and systems, and would undoubtedly allow easier communication with alien
races from neighbouring galaxies :-). But deep down, I do not think that
this need in configuration neutrality is common enough to warrant the
added complexity, and loss of legibility, for most practical cases.

François Pinard   http://pinard.progiciels-bpi.ca

More information about the Python-Dev mailing list