For my project I need to access variables in another file and update them.
In my Database.py file I have the following code:
stock = {"Bread" : 27,
"Car" : 1,
"Banana" : 3000}
In my main program I have this code:
from Database import *
print(stock)
stock['Banana'] -= 100
print(stock)
Running this code returns the expected
{'Car': 1, 'Banana': 3000, 'Bread': 27}
{'Car': 1, 'Banana': 2900, 'Bread': 27}
But since bananas don't magically restore between purchases, I need this variable to change persistently across several runs.