Best practice for config files?

2025-05-22 Thread Michael F. Stemper via Python-list
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 is working fine. However, I wrote it based on t

Re: Best practice for config files?

2025-05-22 Thread Thomas Passin
On 5/22/2025 7:09 PM, Rob Cliffe via Python-list wrote: On 22/05/2025 23:45, Mats Wichmann wrote: On 5/22/25 13:59, Michael F. Stemper via Python-list 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'

Searching for a file

2025-05-22 Thread Rob Cliffe via Python-list
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 import.import_lib function searches for a module in the directories in sys.path). This function would perhaps be best placed in the os.path or os modu

Re: Best practice for config files?

2025-05-22 Thread Mats Wichmann
On 5/22/25 13:59, Michael F. Stemper via Python-list 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 an

Re: Best practice for config files?

2025-05-22 Thread Rob Cliffe via Python-list
On 22/05/2025 23:45, Mats Wichmann wrote: On 5/22/25 13:59, Michael F. Stemper via Python-list 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.Conf

Re: Best practice for config files?

2025-05-22 Thread Grant Edwards via Python-list
On 2025-05-23, Thomas Passin wrote: >> Alternatively look at the PATH envronment variable, which >> contains a list of directories separated by semicolons and which you can >> access as os.environ['PATH'] . > > There is really no reason for a config file to be on the system > path. On Unix/Lin