I've got a large legacy program that is written in OCaml, and I'd like to be able to call some OCaml functions from my Python program.
How can I do this the easiest way?
Directly, no. However, if you create a C
API for your Ocaml library, you can call that API via. Python's ctypes
module or similar. Likewise, if you expose a network service for your OCaml application, Python can call into that.
You might find useful Pycaml, a Python-OCaml interface allowing to call OCaml functions from Python and vice versa.
Be sure to look for the 2011 or later version, which is based on a 2002 version.
Pycaml is no more maintained: nowadays there is pyml and lymp to do that.
pyml: http://pyml.gforge.inria.fr lymp: https://github.com/dbousque/lymp
Both of them are available in opam (opam install pyml lymp). I have not tried them yet, but since I know the author of pyml is very competent, I would bet on that one.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With