Sujet : Re: Best practice for config files?
De : michael.stemper (at) *nospam* gmail.com (Michael F. Stemper)
Groupes : comp.lang.pythonDate : 24. May 2025, 16:05:01
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <100sn6t$oj7m$3@dont-email.me>
References : 1 2
User-Agent : Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.11.0
On 22/05/2025 15.27, Stefan Ram wrote:
"Michael F. Stemper" <michael.stemper@gmail.com> wrote or quoted:
Should I specify the location of the config file with a command-line
option, or is requiring the program to be executed in the directory
containing the configuration file considered acceptable practice?
It was me who digged out this "platformdirs" "user_config_dir"
API using a source code search on my harddisk without any help.
But then I asked my buddy, the chatbot, to explain how to
use it, which I include here, followed by some more words
of my own at the end. Chatbot:
[massive snip]
On Linux:
~/.config/YourAppName
[another one]
Wow, if that's the best practice, I'll settle for second-best!
Somebody who wished to remain anonymous contacted me via email and
suggested that I could have my cake and eat it, too. I am going
ahead with having a default location for the config file, as well
as a command-line option to specify a different file. Blindingly
obvious!
And the default will not be in the directory in which the program
is being run. Your post reminded me of the existence of $HOME/.config
which is obviously the right place for it.
Thanks for all of the suggestions.
-- Michael F. StemperI refuse to believe that a corporation is a person until Texas executes one.