From Python to Mathematica and back again From Python to Mathematica and back again shell shell

From Python to Mathematica and back again


On way to do this:

  • Put your Mathematica code into a plain text file for example make_arr.m
  • Use command line interface of Mathematica:
    • math -script make_arr.m
  • From python invoke the above with the subprocess module
    • subprocess.call(["math", "-script", "make_arr.m"])

Optionally you can use command line arguments in the Mathematica script:

file_name = $CommandLine[[4]]

Further to read