[CentralOH] List in config file

Douglas Stanley douglas.m.stanley at gmail.com
Mon Aug 30 23:17:52 CEST 2010


On Mon, Aug 30, 2010 at 4:54 PM, Tony Zhu <riqemail at gmail.com> wrote:
> I need to store some tasks configuration in a config file. We had a old
> similar program in perl, which uses the Config::Natural module. By that, the
> config file can be written as:
> task{
>     name=task1
>     tools=(tool1
>               tool2)
> }
> task{
>     name=task2
>     tools=(tool2
>              tool3)
> }
> There can be more "task" sections, which could be read into an array by the
> perl config module.
> But I tried the "ConfigParser" package in python, it does not support such
> lists.
> I thought about xml. Of course it can store such data. But the config file
> is supposed to be edited by hand. xml is not so friendly to a notepad. I
> also checked YAML, plists, json. All of them seem to be too complex for my
> simple requirement.
> Does anyone have some python package to recommend?
> Thanks
> Kunpeng (Tony) Zhu
>

Check out configobj:
http://www.voidspace.org.uk/python/configobj.html

It's similar to configparser (in that it uses ini-like files), but
adds things like list support, and nested sections.

Doug

-- 
Please avoid sending me Word or PowerPoint attachments.
See http://www.gnu.org/philosophy/no-word-attachments.html


More information about the CentralOH mailing list