How/where to store calibration values - written by program A, read by program B

MRAB python at mrabarnett.plus.com
Tue Dec 5 11:50:06 EST 2023


On 2023-12-05 14:37, Chris Green via Python-list wrote:
> Is there a neat, pythonic way to store values which are 'sometimes'
> changed?
> 
> My particular case at the moment is calibration values for ADC inputs
> which are set by running a calibration program and used by lots of
> programs which display the values or do calculations with them.
> 
>  From the program readability point of view it would be good to have a
> Python module with the values in it but using a Python program to
> write/update a Python module sounds a bit odd somehow.
> 
> I could simply write the values to a file (or a database) and I
> suspect that this may be the best answer but it does make retrieving
> the values different from getting all other (nearly) constant values.
> 
> Are there any Python modules aimed specifically at this sort of
> requirement?
> 
Some kind of key/value store sounds like the correct solution. I 
wouldn't go as far a database - that's overkill for a few calibration 
values.

I might suggest TOML, except that Python's tomllib (Python 3.11+) is 
read-only!

Personally, I'd go for lines of:

     key1: value1
     key2: value2

Simple to read, simple to write.



More information about the Python-list mailing list