Re: Best practice for config files?
Mats Wichmann <[email protected]>
| Newsgroups | gmane.comp.python.general |
|---|---|
| Message-ID | <[email protected]> |
On 5/23/25 07:35, Chuck Rhode wrote: > On Thu, 22 May 2025 14:59:28 -0500 > "Michael F. Stemper" <[email protected]> wrote: > >> Is requiring the program to be executed in the directory containing >> the configuration file considered acceptable practice? > > Freedesktop.org proposes a specification for where such things ought > to be located: > > + https://specifications.freedesktop.org/basedir-spec/latest/ > > Here's how I do it: > >> def get_xdg_config_home(): > >> """The configuration directory. > >> Normally $HOME/.config. > >> """ > >> result = pathlib.Path.home() / ".config" >> return result platformdirs is useful to handle this kind of stuff - and extends beyond the freedesktop specification to cover Windows as well. I won't rehash the things you can query, since they're on the page: https://pypi.org/project/platformdirs/