I want to share a variable between multiple Python scripts that are open. One does not import another. Imagine this:
main1.py
#do something to share the dict that's about to be assigned at the bottom (optional)
#by that i mean i can still import it from a module or something else
main = {"apples":"are fine"}
print(main['apples'])
main['apples'] = "are delicious"
main2.py
#do something to get the dict from the first script or get the shared var
input()
#^^^ to wait until the first script changes the apples value and then access it manually
print(main['apples'])
>>> "are delicious"
This problem is based on the worker system that pythonanywhere provides to handle incoming requests quicker. But the thing is, it involves having multiple python flask scripts running at the same time and as I use the flask app to store data, I somehow need a way of sharing a dict between these two instances.
To rephrase that:
You could use pyro4 + pickle to share data between applications over network (localhost 127.0.0.1). https://docs.python.org/3/library/pickle.html https://pyro4.readthedocs.io