Where to store python application configuration files on Windows

I have a python program that should work on Windows and Linux. There are some configuration options that I usually store in a file in a subdirectory of the program directory.

On Windows, I converted it to exe and created an installer for it. And now I have a problem with the configuration file.

What is the best place to save in the configuration file? I read that for Windows os.environ['APPDATA']+'myAppName' is the path to use. Is it correct? Is this standard? Will it work in all versions of Windows, at least with XP (and at least in English and Spanish)?

PD: I'm not interested in using ConfigParser. The Config file is in my own format, and I have working code to read / write.

+4
source share
2 answers

Saving settings in the user directory is usually a good idea. In most Unices, just save the (preferably prefix) file in your home directory. In OS X, you want to create a directory for your application in the Users Library folder and save your files there. On Windows, APPDATA is a good place to create a directory for your application. It should work on all Windows localizations, and it looks like it is also available on Windows XP.

+3
source

On Linux, the configuration file is usually saved in the users home directory, for example ~/.myprogramrc . On Windows Vista and above, users also have a home directory (/ Users / username), and he would recommend saving your settings there in a subfolder (/ Users / useranem / myprogram). Saving the settings in the application folder will result in UAC warnings.

In Windows XP, users do not have a home folder. Some programs make a choice in the setting in the "My Documents" folder, which, I think, is as good as any.

+2
source

All Articles