Best way to store config or preferences in a multi-platform way.

Ivan Illarionov ivan.illarionov at gmail.com
Thu May 1 10:43:30 EDT 2008


On Thu, 01 May 2008 08:30:03 -0500, Nick Craig-Wood wrote:

> Lance Gamet <lance at gamet.com> wrote:
>>  This project will store most of its actual data in a shared-database,
>>  but I have a small amount of user specific data that I need to be
>>  stored like configuration or preferences for example, the list of
>>  databases that the program should connect to.
>> 
>>  On Unix this might be a .file, on windows this could be in the
>>  registry, or an ini file or an xml file in ProgramData or AppData or
>>  something.
>> 
>>  Is there a pythony way to store such config data, perhaps there is
>>  already a standard python package for such a purpose?
> 
> I've found
> 
>   http://docs.python.org/lib/module-ConfigParser.html
> 
> To be easy to use and built in.  It makes human readable / editable .ini
> - like files.

IMO .ini-like config files are from the stone age. The modern approach is 
to use YAML (http://www.yaml.org). 

It has a lot of advantages over .ini and xml, YAML syntax was designed to 
be easily mapped to Python data types and is very similar to Python.

More at http://en.wikipedia.org/wiki/YAML

As for where to store it, I completely agree with Nick Craig-Wood.

-- 
Ivan



More information about the Python-list mailing list