Embedding OCaml within Python

Max Powers max_powers280 at hotmail.com
Wed Apr 28 04:19:53 EDT 2004


I've spent an interesting day searching the web for help with calling
OCaml functions from a python program and have come to the newsgroup
for some advice (unfortunately I'm learning both languages at the same
time, so maybe I've missed something obvious!)

The situation is this; I've got a large legacy program that is written
in ocaml, within which there's a parser. I'd like to be able to call
that parser from my python program (actually it's really a GUI using
wxPython), rather than reimplement it (and then have to maintain two
parsers into the future).

I've come across Viper, which looks like a python compiler/interpreter
implemented in OCaml, so I imagine that I could get it to do some
magic tricks to call a ocaml library from python, but I think that's
doomed to failure because of the C extensions of wxPython.

I've stumbled across Pycaml, but don't quite understand how to use it
to call ocaml from python. Alternatively I think I can wrap the ocaml
library in a C wrapper and then call that from python.

Can anyone give advice/share experiences? Is combining OCaml with
python relatively straightforward with a bit more effort, or am I in
for a world of pain?

Thanks,
Max



More information about the Python-list mailing list