[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

preferences file

On Thu, Jan 24, 2019 at 02:42:59PM -0500, Dave wrote:

> 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?

Centralize as much as possible - if there's a database
consider putting user options into that.

Standard library helps in keeping dependencies down (ConfigParser).

> 2. File format favored and why - ini, JSON, etc?

Stay with something human readable.

INI is nice, but doesn't nest well, as was said. And it does
not easily lend itself to "list" style options.

> 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?

pip3 search xdg:

	xdg (3.0.2)          - Variables defined by the XDG Base Directory Specification
	python-xdgapp (1.0)  - Python XDG for Applications
	mir.xdg (1.0.0)      - XDG Base Directory support
	dirspec (13.08)      - XDG Base and User directories implementation
	xdgspec (0.1.1)      - Convenient access to XDG Base Directory Specification variables
	pyxdg-open (0.2.1)   - Opens URL or file in user preferred application (xdg-open replacement).

Depending on UI toolkit:


GPG  40BE 5B0E C98E 1713 AFA6  5BC0 3BEA AC80 7D4F C89B