> I'm doing a small application and want to add user preferences. Did
> some googling to see if there are standard Python ways/tools, but it
> seems not so much. My specific questions are:
> 1. Best practices for a user preference file/system?
use as many default parameters as you can so that the
user can run it without any configuration changes if
what i did was this:
config.py which sets the default values used by other
modules which then gets imported by any module that needs
those values. these can be changed during operation if
needed, but are not saved unless specifically desired.
if the user desires to save a different configuration
than the above default values then that file is saved to
i also made sure to upload my app to PyPI making sure
the <app-name> is unique enough there (but also checked
it via the packages listing for Debian and Ubuntu to make
sure there wasn't a conflict).
> 2. File format favored and why - ini, JSON, etc?
configuration info and saved user games i've ended up
using json. it is easy to load and save and should be
> 3. File location? I'm using Ubuntu and I believe that the correct
> location would be home/.config/<app-name> . What about Mac and Windows?
user saved info would go into:
should be ok for any posix system (Debian, Ubuntu, MacOS)
if the system doesn't have home directories but does have
/usr/local you can put things in there (just check to make
sure first that you aren't clobbering someone else's directories
or files :) ).
> Would like to find a Python library that handles all of this, but so far...
every recommendation so far i've seen looks to be
either not adopted widely or not actively developed/maintained.