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

Diez B. Roggisch deets at nospam.web.de
Thu May 1 08:34:17 EDT 2008


Lance Gamet schrieb:
> Hi, python beginner starting a new project here.
> 
> 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?
> 
> My app uses Qt, and Qt has its method of doing it (QSettings), but for 
> architectural reasons I don't want to use it.
> 
> Could sqlite be an option perhaps? I am still undecided if the ability 
> for the user to edit the file independently of the program is a good or 
> bad thing.

I'd go for .file in ConfigParser-format that resides in the users 
home-directory. ConfigParser is a standard lib module for .ini-like files.


Diez



More information about the Python-list mailing list