How to import data from a file and append it to a Python list?
<p>This is what I've tried.</p>

<pre><code>foo = {}
foo['bar'] = [{'a': '1', 'b': '2'}, {'c':'3', 'd':'4'} ]
import othervalues
</code></pre>

<p>This is the content of othervalues.py</p>

<pre><code>foo['bar'].append({'e': '5', 'f': '6'})
</code></pre>

<p>However when I try to run this, it fails saying that foo isn't defined.</p>

<p>How can I append to the original list by using values stored in another file?</p>

<p>In othervalues you could have:</p>

<pre><code>def fooadd(foo):
    foo['bar'].append({'e': '5', 'f': '6'})
</code></pre>

<p>And then, in your normal code:</p>

<pre><code>import othervalues
othervalues.fooadd(foo)
</code></pre>

python list import