472,139 Members | 1,438 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,139 software developers and data experts.

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

On 2008-05-01 13:37, Lance Gamet wrote:
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?
I don't think this is a Python question, but more a platform
question. Users on different platforms will expect configuration
data in different places. It's usually best to stick to the platform

Python has modules available for accessing INI-files, XML-files
and also for the Windows registry, so that part is easy.
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.
If the user is meant to change the data, then you should make this
easy for the user. Putting such data into SQLite will not satisfy that
requirement :-)

If you don't have a GUI tool for the user to change config settings,
then it's probably best to put the configuration into a file that's
easy to edit, e.g. an INI file.

Here's a nice module that supports both reading and writing
INI files:


Marc-Andre Lemburg

Professional Python Services directly from the Source (#1, May 01 2008)
>>Python/Zope Consulting and Support ... http://www.egenix.com/
mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/
mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/
__________________________________________________ ______________________

:::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,MacOSX for free ! ::::
eGenix.com Software, Skills and Services GmbH Pastor-Loeh-Str.48
D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg
Registered at Amtsgericht Duesseldorf: HRB 46611
Jun 27 '08 #1
0 2097

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

6 posts views Thread by msnews.microsoft.com | last post: by
3 posts views Thread by ucasesoftware | last post: by
3 posts views Thread by gordon | last post: by
3 posts views Thread by Nemisis | last post: by
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.