Return variables in a for loop from imported script function : <p>I have two .py files (test1.py &amp; test2.py)</p>

<p>Now I want in a loop to run test1.py and to import a function from test2.py, let it execute and return the values back to test1.py</p>

<p>test1.py:</p>

<pre><code>from test2 import fun

for i in range(5):

    % do stuff

    fun(times, data)

    xarr[i] = x
    yarr[i] = y
</code></pre>

<p>test2.py:</p>

<pre><code>def fun(times,data):

    % do stuff

    return [x,y]
</code></pre>

<p>It works to execute, but the variables xarr[i] and yarr[i] are not generated</p>
