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

Greg Walters greg.gregwa at gmail.com
Wed Dec 27 04:53:42 EST 2023


Many years ago, Fredrik Lundh provided an answer for this question
on his website effbot.org.  Unfortunately that site has gone, but luckily,
it has been preserved in the "wayback machine"...

https://web.archive.org/web/20200724053442/http://effbot.org:80/pyfaq/how-do-i-share-global-variables-across-modules.htm

In short, create an empty file named something like 'config.py' or
'shared.py' in a folder that both scripts can use.
Import the file in both scripts.

import shared

Then when you want to share a value, use...

shared.variablename=3.14159

The file can then be accessed by both scripts.

The biggest caveat is that the shared variable MUST exist before it can be
examined or used (not surprising).

I sincerely hope this helps.

Greg
-- 
*My memory check bounced*



Greg Walters


More information about the Python-list mailing list