[Openmcl-devel] access Mac OS python interpreter from clozure?

Jeff Caldwell jcaldwell at clozure.com
Wed Oct 1 17:48:43 PDT 2014


The streams are buffered and not getting flushed. Try #'force-output.
You may need to do something similar from within python to get the
results back to Common Lisp.

Jeff


On Wed, Oct 1, 2014 at 7:15 PM, Mark Klein <m_klein at mit.edu> wrote:
>
> To add more detail to my previous question, I wonder if I can do something
> like the following:
>
> (defun test ()
>   (setq p (run-program "python" nil
>                        :wait t
>                        :input :stream
>                        :output :stream))
>   (setq is (external-process-input-stream p))
>   (setq os (external-process-output-stream p))
>   (loop do (format is "~A~%"  (read-line))
>            do (format t "~%~A" (read-line os))))
>
> The idea is that this would create a process running python and allow me to
> send and receive text to it. The code above doesn’t work, the read from the
> external process output stream never returns, but perhaps there’s a simple
> fix?
>
>     Thanks,
>
> Mark
>
>
> Hi,
>
> I’d like to create input and output streams that connect with the python
> interpreter that comes included with Mac OS X so I can invoke python
> subroutines from lisp and get the results. Does anyone have any suggestions
> about how that can be done? I see that Clozure allows running other programs
> as subprocesses
> (http://ccl.clozure.com/ccl-documentation.html#Running-Other-Programs-as-Subprocesses)
> but it’s not clear to me if I can use that to interact with a program like
> python, as oppose to simply invoking a program like “cat” and getting the
> results it returns when it completes.
>
> Thanks for your help!
>
> Mark
>
> -------------------------------
> Mark Klein
> http://cci.mit.edu/klein
>
> Principal Research Scientist
> Center for Collective Intelligence
> Massachusetts Institute of Technology
>
> Visiting Researcher
> Dynamic and Distributed Information Systems Group
> University of Zurich
>
>
> -------------------------------
> Mark Klein
> http://cci.mit.edu/klein
>
> Principal Research Scientist
> Center for Collective Intelligence
> Massachusetts Institute of Technology
>
> Visiting Researcher
> Dynamic and Distributed Information Systems Group
> University of Zurich
>
>
> _______________________________________________
> Openmcl-devel mailing list
> Openmcl-devel at clozure.com
> http://lists.clozure.com/mailman/listinfo/openmcl-devel
>



More information about the Openmcl-devel mailing list