0

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 1

4

I think OS.Process.system "python myscript.py" should work. See: http://sml-family.org/Basis/os-process.html

Sign up to request clarification or add additional context in comments.

6 Comments

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?
@arizq29, I suggest opening a new question that contains the complete SML code you're using too.
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.
@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.
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?
|

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.