How to create a dict based on such a file?
Steven D'Aprano
steve+comp.lang.python at pearwood.info
Mon Feb 14 18:06:58 EST 2011
On Mon, 14 Feb 2011 11:25:00 -0800, Dan Stromberg wrote:
> FWIW, the creator of the many .ini format(s), Microsoft, no longer
> recommends using .ini files.
That's because they want people to use the registry.
INI files are simple, easy to parse, lightweight, and human readable and
human writable using nothing more than a text editor. For many purposes,
they are perfectly fine. As I see it, the biggest problems with INI files
are:
* the INI file module that comes with Python is quite primitive;
* there are many slightly different behaviours you might want in an INI
file, and no clean or obvious way to tell which one you are dealing with
just from the file.
E.g. if you repeat a key twice, does the second line override the first,
or add a second value, or is it an error?
INI files aren't suitable for everything, but there's no need to avoid
them just because Microsoft don't want you using them, or because they're
uncool or something...
Rant: what I *really hate* is when people use XML just because XML is the
in-thing, not because they need it. Instead of:
[main]
key = value
food = spam
colour = green
you get something like this:
<?xml version="1.0"?>
<main>
<entry name="key" value="value"></entry>
<entry name="food" value="spam"></entry>
<entry name="colour" value="green"></entry>
</main>
--
Steven
More information about the Python-list
mailing list