Calling Python from Allegro Lisp
laotseu
bdesth at nospam.free.fr
Sun Jul 14 16:14:40 EDT 2002
Marco Antoniotti wrote:
> 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.
(begin-troll ()
(print "But ? There is *no* better language than Python !!!?"))
laotseu
More information about the Python-list
mailing list