Where should the configuration files be stored?

I am writing an application in python (using wxPython for gui) and I am looking for a platform independent way to decide where to store the application parameter files. On Linux systems, where do you usually store application settings files? How about on Mac and Windows (all modern versions)?

Ideally, I would like to have a module that provides a platform agnostic interface for finding these files. Does something like this already exist?

+4
source share
3 answers

wxPython has your back. You want wx.StandardPaths. There a good example is included in the wxPython demo.

+6
source

There is a standard for this at freedesktop.org, which might be useful:
http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html

+3
source

There really is no standard way in linux. A lot of programs, especially the new python programs I've seen, use ~/.config/appname/ . Of course, older ones like bash, vi, etc. Just add the hidden file to ~/ . It depends on what these settings are.

This is obviously a user launcher. System programs usually store their configuration files somewhere in /etc/

Edit:

~/.config/appname/ seems more standard than I thought.

  ~ $ ll config
 total 84K

 drwxr-xr-x 2 falmarri 4.0K 2010-12-17 09:48 akonadi /
 drwxr-xr-x 2 falmarri 4.0K 2010-12-04 15:48 autokey /
 drwxr-xr-x 2 falmarri 4.0K 2010-11-06 01:45 autostart /
 drwx ------ 2 falmarri 4.0K 2010-11-23 22:32 enchant /
 drwxr-xr-x 2 falmarri 4.0K 2010-11-25 21:13 FreeCAD /
 drwx ------ 2 falmarri 4.0K 2010-12-21 09:16 gtk-2.0 /
 drwx ------ 3 falmarri 4.0K 2010-12-11 13:43 ibus /
 drwxr-xr-x 2 falmarri 4.0K 2010-11-06 02:20 kde.org/
 drwxr-xr-x 2 falmarri 4.0K 2010-11-06 02:46 qtcurve /
 drwxr-xr-x 2 falmarri 4.0K 2010-11-17 13:49 Trolltech /
 drwxr-xr-x 2 falmarri 4.0K 2010-11-17 23:29 vlc /
 -rw-r - r-- 1 falmarri 31K 2010-12-21 20:51 Trolltech.conf
 -rw ------- 1 falmarri 632 2010-11-06 01:40 user-dirs.dirs
 -rw-r - r-- 1 falmarri 5 2010-11-06 01:40 user-dirs.locale
0
source

Source: https://habr.com/ru/post/1333139/


All Articles