Updating variables across files persistently
<p>For my project I need to access variables in another file and update them.</p>

<p>In my Database.py file I have the following code:</p>

<pre><code>stock = {"Bread" : 27,
"Car" : 1,
"Banana" : 3000}
</code></pre>

<p>In my main program I have this code:</p>

<pre><code>from Database import *

print(stock)
stock['Banana'] -= 100
print(stock)
</code></pre>

<p>Running this code returns the expected</p>

<pre><code>{'Car': 1, 'Banana': 3000, 'Bread': 27}
{'Car': 1, 'Banana': 2900, 'Bread': 27}
</code></pre>

<p>But since bananas don't magically restore between purchases, I need this variable to change persistently across several runs.</p>