Skip to content Skip to sidebar Skip to footer

How To Get Output Of A Lisp Program Into Python?

I've got a very large Lisp project whose output I'd like to programmatically pipe to a Python program, i.e. use Python to call the Lisp program on some input and get the output bac

Solution 1:

The error in your Python code is clear: No such file or directory.

You need to tell in your Python code which application you want to run in a way that it actually finds it.

It's also not clear why you save a Lisp executable somewhere named hello, but you are not trying to call it. With the necessary path. Your code tries to call Clozure CL - without the necessary path - but why? You just saved an executable. Why would you call Clozure CL to run it? I would also save the executable with prepending the kernel - that makes it self-contained.

Example:

Calling Clozure CL:

rjmba:~ joswig$ ccl
Welcome to Clozure Common Lisp Version 1.9-dev-r15612M-trunk  (DarwinX8664)!

Defining the main function:

? (defun main () (print"hello"))
MAIN

Saving an executable:

? (save-application "hello":toplevel-function#'main :prepend-kernel t)

Running the new executable from the same directory:

rjmba:~ joswig$ ./hello

"hello"

Calling a Clozure CL application with an argument:

bash-3.2$ ccl
Welcome to Clozure Common Lisp Version 1.9-dev-r15612M-trunk  (DarwinX8664)!

The function ccl::command-line-arguments returns the arguments as a list. The first item is the called application itself.

? (defun main ()                                                                
    (print (second (ccl::command-line-arguments))))
MAIN

? (save-application "hello":toplevel-function#'main                                   :prepend-kernel t)

Calling it:

bash-3.2$ ./hello hello!

"hello!"

Post a Comment for "How To Get Output Of A Lisp Program Into Python?"