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

Chris Green cl at isbd.net
Sat Dec 30 06:05:31 EST 2023


Peter J. Holzer <hjp-python at hjp.at> wrote:
> [-- text/plain, encoding quoted-printable, charset: us-ascii, 40 lines --]
> 
> On 2023-12-29 09:01:24 -0800, Grant Edwards via Python-list wrote:
> > On 2023-12-28, Peter J. Holzer via Python-list <python-list at python.org> wrote:
> > > On 2023-12-28 05:20:07 +0000, rbowman via Python-list wrote:
> > >> On Wed, 27 Dec 2023 03:53:42 -0600, Greg Walters wrote:
> > >> > The biggest caveat is that the shared variable MUST exist before it can
> > >> > be examined or used (not surprising).
> > >> 
> > >> There are a few other questions. Let's say config.py contains a variable 
> > >> like 'font' that is a user set preference or a calibration value 
> > >> calculated by A to keep with the thread title. Assuming both scripts are 
> > >> running, how does the change get propagated to B after it is set in A
> > >
> > > It isn't. The variable is set purely in memory. This is a mechanism to
> > > share a value between multiple modules used by the same process, not to
> > > share between multiple processes (whether they run the same or different
> > > scripts)
> > >
> > >> and written to the shared file?
> > >
> > > Nothing is ever written to a file.
> > 
> > Then how does it help the OP to propogate clibration values from one
> > program to another or from one program run to the next run?
> 
> It doesn't. See his second mail in this thread, where he explains it in
> a bit more detail. I think he might be a bit confused in his
> terminology.
> 
If I am the OP (I suspect I may be) I have gone with JSON stored in a
file to provide what I need.  The Python json package is very simple
to use and with an 'indent=' setting the resulting json is reasonably
human readable which is all I need.

Thus programs simply read the values from the json file into a
dictionary of dictionaries and the 'updater of values' program can
write them back after changes. 

-- 
Chris Green
·


More information about the Python-list mailing list