4
$\begingroup$

I have this notebook:

arg1 = "input.txt";
arg2 = "output.txt";
u1 = Import[arg1, "Table"];
u2 = u1(*extremely complicated and long chain of operations*);
Export[arg2, u2]

and I would like to run it in a Python program like this:

def run(arg1,arg2):
    my_mathematica_code(arg1,arg2)

for i in range(100):
    run("input{}".format(i), "output{}".format(i))

How can I do this? Preferably without GUI and several threads in parallel (I can use 4 cores in Mathematica).

$\endgroup$
3
  • 1
    $\begingroup$ related - if you don't mind putting things into a function: mathematica.stackexchange.com/questions/4643/… $\endgroup$ Commented Aug 20, 2013 at 12:08
  • $\begingroup$ Does this also works for code in my notebook which lies at some arbitrary location on my machine? $\endgroup$ Commented Aug 20, 2013 at 12:36
  • $\begingroup$ Why not open a connection to a kernel with subprocess.Popen? Then you can communicate with that via pipes. $\endgroup$ Commented Mar 20, 2018 at 4:06

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.