mwm at mired.org
Sun Dec 26 08:34:54 CET 2004
Aaron <flamesrock at gmail.com> writes:
> I'm interested in creating a large number of configuration files which I
> have no experience doing in python. The fields will be static for the most
> part. But design changes and I might want to add new fields in the future..
> My question is - whats the best module for creating, reading, and editing
> these files(something like an INI)? I want it to be powerful,
> yet simple and minimalistic, not requiring a huge amount of overhead.
> I've heard of xml, and have seen it used in both html fashion, and
> likewise, without any tags at all- just spaces in between entries; why is
> this? CSV is another thing I've seen thrown around on online
> documentation. Whats the difference between the two, and which one should
> I use(if either)?
M.E. Farmer already suggested the ConfigParser module, and I have to
concurr with him - it basically handles INI files.
XML is verbose. It allows the construction of complex data structures
(it's been called S-expressions with brokeits). It's primary advantage
is that there are tools for dealing with XML sanely - XML editors,
validators, parsers, and similar things. Without those tools, it can
be a PITA to deal with. So if your configuration is simple enough to
be captured by an INI file, avoid XML. If not, then googling for "xml
editor windows free" turns up a fair number of hits. For Unix, I used
to use an XML editor called Ted that was written in Python, but can't
turn anything up on google. There are xml editors for both KDE and
Gnome. Personally, I use psgml, which is an emacs package that handles
both xml and it's parent sgml.
CSV stands for Comma Separated Values. It's primarily an interchange
format for spreadsheet programs. While there is a default csv module
(that also handles tab separated values, and other arbitrary
separators), it's not the right tool for use as a config file.
Mike Meyer <mwm at mired.org> http://www.mired.org/home/mwm/
Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.
More information about the Python-list