From Python to Mathematica and back again
<p>I wrote a Python script, which produces an output that goes to a file.
This is read as an input file by Mathematica, that then uses it to make some operations and finally returns another output file. 
In turn, this last file should be read by the same initial Python script, to perform some more operations. </p>

<p>My question is: what is the simplest (but efficient) way to do that?</p>

<p>I will write in the following a (very simplified) example of what I am dealing with. I start with my python script <code>python_script.py</code>: this produces an array <code>arr</code> that is saved in the file <code>"arr.txt"</code></p>

<pre><code>import numpy as np 
arr = np.arange(9).reshape(3,3)
np.savetxt('arr.txt', arr, delimiter=' ')
</code></pre>

<p>This file is read by my Mathematica notebook <code>nb_Mathematica.nb</code>. This for example could produce another array, in turn saved in another file, <code>"arr2.txt"</code></p>

<pre><code>file = Import["arr.txt","Table"]
b = ArrayReshape[file, {3,3}]
c = {{1,1,1},{1,1,1},{1,1,1}}
d = b + c
Export["arr2.txt", d]
</code></pre>

<p>And now <code>"arr2.txt"</code> must be read by the original Python script. How is it possible to do that? How in particular can I stop the Python script, start Mathematica and then go back to the Python script?</p>