krussell4 at home.com
Fri Sep 22 03:30:38 CEST 2000
Jordi Inglada wrote:
> I am looking for modules which wrap other languages son they can be used
> in python scripts. I am thinking about using a prolog kernel or a
> clisp inference engine, though others are also welcome (scheme, haskell,
Not sure whether you're talking about CLIPS or Clisp. (Don't you just
hate too similar names for too similar languages?) Anyway, my comments
below should apply to either one.
> I have seen something like this for clips at
> <http://starship.python.net/crew/gandalf/DNET/AI/> but it looks like
> it works for old versions of python.
> I guess one solution would be using SWIG to generate de bindings for
> those which are written in C (GNUProlog, for instance), but I wouldn't
> want to re-invent de wheel!!
You probably don't need full-blown SWIG style wrappers for this kind
of thing. All the languages you're talking about (Python, CLIPS,
Lisp, Scheme, Prolog, ... not sure about Haskell) have interactive
modes where a listener sits and waits for input from a user. It's
easy to have your program simulate a live user and send input to
the other language's interactive interpreter -- e.g., Python sends
a Lisp process the string "(+ 3 4)", Lisp evaluates it, sends Python
back the string "7", and so on.
You can find an example of Python talking to SWI Prolog using pipes
-- look for the Pylog module on the Vaults of Parnassus. If you want,
I can send you a sort of similar example of Python talking to Sicstus
Prolog using sockets.
Two independent processes talking to each other in strings should be
good enough for most expert system uses you're likely to need. If
you want the two languages to be slinging actual complex data
structures back and forth, you're in for more work, and I'm not
sure SWIG will make your life much easier. If for some reason I
wanted to do it this way, my first reaction would be to consider
Rice's MzScheme, since it has the most explicit documentation I've
seen on how to embed its interpreter in another program.
Finally, if you only need pretty basic expert system capabilities,
you might consider using the Holmes package written by Mark Lutz
entirely in Python.
-- Kevin Russell
More information about the Python-list