ANN : ConfigObj 3.0.0 - Simple config file parsing
Fuzzyman
michael at foord.net
Thu May 27 12:13:50 EDT 2004
Wilk <wilkSPAM at OUTflibuste.net> wrote in message news:<87vfijyxm1.fsf at blakie.riol>...
> michael at foord.net (Fuzzyman) writes:
>
> > There have been a couple of config file 'systems' announced recently,
> > that focus on building more powerful and complex configuration files.
> > ConfigObj is a module to enable you to much more *simply* access
> > config files.
>
> What do you thing about yaml for config file ? it's very pythonic with
> indentation :
>
> import yaml
> print yaml.load("""
> rub1:
> - one
> - two
> rub2:
> - three
> - four
> """).next()
>
> {'rub1': ['one', 'two'], 'rub2': ['three', 'four']}
>
> it can also work on the other side :
>
> print yaml.dump({'rub1': ['one', 'two'], 'rub2': ['three', 'four']})
> ---
> rub1:
> - one
> - two
> rub2:
> - three
> - four
I'm sure YAML is fine - I think ConfigObj is still probably 'simpler'.
A basic config file can be created with :
config = ConfigObj(filename)
config['keyword1] = value1
config['list keyword] = [value2, value3, value4]
.
.
config.write()
You can then read it back with :
config = ConfigObj(filename)
Lot's of extra options of course. The created config files look like
config files that most people will be used to creating :
"keyword1" = "value1"
"keyword2" = "value2"
.
.
.
Regards,
Fuzzy
http://www.voidspace.org.uk/atlantibots/pythonutils.html
More information about the Python-list
mailing list