Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
[Caml-list] Calling Ocaml from Python
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2004-04-29 (03:09)
From: Max Powers <max_powers280@h...>
Subject: [Caml-list] Calling Ocaml from Python
This is a bit of a repeat of a question that I posted to comp.lang.python 
(sorry to anyone who was there too!). I'm looking for some advice on 
integrating a python GUI with an OCaml library. (Note: I'm fairly new to 
both ocaml and python; more of a perl and c++ programmer!)

Basically the story is this, I'm building a GUI on the front of an existing 
OCaml tool. I'm writing the GUI in wxPython (there are a number of reasons 
why, I investigated various caml gui toolkits and unfortunately they didn't 
quite satisfy the requirements I had). Currently the GUI is envisaged as a 
glorified configuration file editor; it should help users to generate 
configuration files that are then handed to the ocaml tool to execute.

The problem is this, both the python GUI and the ocaml tool need to know how 
to parse/understand the configuration file format, and I'd like to write the 
parser once (in ocaml, using ocamllex/yacc probably) and use it twice (in 
the GUI and the base tool). My challenge now is to figure out how to call 
the ocaml parser library from python.

I currently have two possibilities in mind. Surfing the web uncovered 
Pycaml, which suggests integration both ways, however from the examples I 
only understand how python can be called from ocaml (not the other way).

The second possibility is to wrap the ocaml module in a c library that can 
then be imported into the python code.

What I'm hoping is that someone on the list has tried this sort of thing 
before and can give a little advice on the best way forwards (and hopefully 
reduce the number of blind alleys I explore!).

(sorry for the length of the message and any abuse of the nomenclature!)

Personalise your phone with chart ringtones and polyphonics. Go to

To unsubscribe, mail Archives:
Bug reports: FAQ:
Beginner's list: