I was wondering if it is possible to call a python file in an SML program, and if so how can you do it? I have tried researching how to do this, but have only found documentation on how to call other SML files.
1 Answer
I think OS.Process.system "python myscript.py" should work. See: http://sml-family.org/Basis/os-process.html
6 Comments
arizq29
I am receiving a tycon mismatch error when I try to implement this. I added my sml code as well as the error and the method in python I am trying to call. Can you see where I went wrong?
Alejandro C.
@arizq29, I suggest opening a new question that contains the complete SML code you're using too.
arizq29
My entire SML code is contained in the link above. It is very short, I am just trying to call a method from a python file I wrote in SML. The link also includes the error I am receiving. The SML code is below the error.
Alejandro C.
@arizq29 why are you doing a recursive call? The problem is that you're taking the return value of
interpreter (which is the return value of OS.Process.system, which is OS_Process.status), binding it to s, and then trying to concatenate (^) s with a string. That's the type mismatch.arizq29
Ok, so how would I go about calling the function in python using the arguments received from the SML function then? Would I just get rid of the concatenation so its OS.Process.system ("python interpreter.py")? That allows the sml program to compile and returns me this
val interpreter = fn : string * string -> Word32.word val it = () : unit My program in python should output a text file, so is Word32.word the output I should expect? |