How can I reference a outside variable from within a function?
<p>UPDATE: Sorry I was wrong with my assumption of the problem.  Its due to me trying to make the function parallel and have multiple proceses change the same dictionary.  How can I design my function so it allows for this? If I have to send the dictionary(in this case) then it'll keep overwriting itself and can't span over all the cores. I'm happy to redesign the function but not sure how i can do it and still spread it over multiple cores.</p>

<p>To simplify, I basically have something like the following:</p>

<pre><code>list = [1,2,3,10]
dictionary = {}
for x in list:
    for xx in range(100):
        for xxx in range(100):
            dictionary[x]=xx*xxx
</code></pre>

<p>This works, but when I wrap the for loop in a function, I get:
 NameError: global name 'dictionary' is not defined</p>

<pre><code>def test(x):
        for xx in range(100):
            for xxx in range(100):
                dictionary[x]=xx*xxx
</code></pre>

<p>I know this has something to do with the namespace but I don't want to send variables to the function in this case because I think it'll overwrite the variable dictionary.  How can I reference the dictionary variable while in the function?  The reason I ask is I want to create a process that spans multiple cpu's, so I don't want to declare the variables in each function.</p>

<p>I'm using functions but if I need to use classes or there's another way to get around this then please me know and I'll rethink my approach.</p>
