Re: Best practice for config files?

2025-05-24 Thread Jason H via Python-list
On 22/05/2025 20:59, Michael F. Stemper wrote: I recently wrote a program to do some record-keeping for me. I found myself hard-coding a bunch of different values into it. This didn't seem right, so I made my first use of configparser.ConfigParser(). Created the configuration file and everything

Re: Best practice for config files?

2025-05-24 Thread Michael F. Stemper via Python-list
On 22/05/2025 15.27, Stefan Ram wrote: "Michael F. Stemper" 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

Re: Searching for a file

2025-05-24 Thread Mats Wichmann
On 5/23/25 16:05, Rob Cliffe via Python-list wrote: On 23/05/2025 18:55, Mats Wichmann wrote: On 5/22/25 21:04, Rob Cliffe via Python-list wrote: It occurs to me that it might be useful if Python provided a function to search for a file with a given name in various directories (much as the i

Re: Searching for a file

2025-05-24 Thread Rob Cliffe via Python-list
On 25/05/2025 00:18, Mats Wichmann wrote: On 5/23/25 16:05, Rob Cliffe via Python-list wrote: On 23/05/2025 18:55, Mats Wichmann wrote: On 5/22/25 21:04, Rob Cliffe via Python-list wrote: It occurs to me that it might be useful if Python provided a function to search for a file with a give

Re: Best practice for config files?

2025-05-24 Thread Mats Wichmann
On 5/23/25 07:35, Chuck Rhode wrote: On Thu, 22 May 2025 14:59:28 -0500 "Michael F. Stemper" 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

Re: Searching for a file

2025-05-24 Thread Chris Angelico via Python-list
On Sun, 25 May 2025 at 10:05, Rob Cliffe via Python-list wrote: > Yes, but if I understand correctly, they all start from a single > directory (and work downwards if required). > My suggestion involved searching a *list* (possibly multiple lists) of > directories. for dir in dirs: try: open(d