Calling Python from Allegro Lisp
Marco Antoniotti
marcoxa at cs.nyu.edu
Fri Jul 12 11:35:32 EDT 2002
Thomas Guettler <zopestoller at thomas-guettler.de> writes:
> Hi!
>
> I have an old application which needs to call python.
> The old app is written in allegro lisp.
>
> I tried the following:
> (defparameter hlib "c:\\winnt\\system32\\python22.dll")
It's be better to say
(defparameter *hlib* (parse-namestring "c:\\winnt\\system32\\python22.dll"))
> (probe-file hlib)
This will just return the above pathname or NIL.
> (ct:defun-dll Py_Initialize()
> :return-type :void
> :library-name hlib
> :entry-name "Py_Initialize")
> (ct:defun-dll PyRun_SimpleString((s :char *))
> :return-type :long
> :library-name hlib
> :entry-name "PyRun_SimpleString")
>
> (Py_Initialize)
> (setq foo "print 'foo'")
> (PyRun_SimpleString (cref (ct:char *) foo 0))
>
> But get:
> """
> The first element (CREF (CHAR *) foo 0) of a function
> application is not a function name
> """
After your setting up of your Python Library you have ended up with a
function called
PyRun_SimpleString
(Note that ct:defun-dll may not be the best way to achieve this)
You are calling the above function of the value that the macro CREF.
However, note that CREF is in the CT package and that you may or may
not have that symbol available in your code snippet. Try putting the
fully qualified name in your code: CT:CREF.
> What could be wrong.
(with-sarcasm ()
(print "Wanting to use Python?"))
> I am new to lisp
Then stick with it. Rewrite the Python stuff in a better language and
live happier everafter.
Cheers
--
Marco Antoniotti ========================================================
NYU Courant Bioinformatics Group tel. +1 - 212 - 998 3488
719 Broadway 12th Floor fax +1 - 212 - 995 4122
New York, NY 10003, USA http://bioinformatics.cat.nyu.edu
"Hello New York! We'll do what we can!"
Bill Murray in `Ghostbusters'.
More information about the Python-list
mailing list