Tag Info

New answers tagged


Here is an approach that works on Mac OS X or unix-like systems without the need to explicitly create any temp directory: code = "print \\\"hello, starting\\\" for i in [1,2,3]: \t print i*i " (* ==> "print \\\"hello, starting\\\" for i in [1,2,3]: print i*i " *) RunProcess[$SystemShell, "StandardOutput", "printf \"" <> code <> ...


Here is a more robust solution using Process: Clear[runPython]; runPython::badCommand ="Python code failed to run with message `StandardError`"; $pyimports="from random import randint "; runPython[str_String, imports_:$pyimports] := Module[ {pyscrpt = ToString[$pyimports<>str, CharacterEncoding->"ASCII"], file=CreateTemporary[], res}, ...

Top 50 recent answers are included