> I was wondering if anyone has tried somehow calling Jython functions
> from within Clojure, and how you went about doing this if so.  I have
> not used Jython, but I would imagine the Jython interpreter can be
> invoked in the same way as any other java code, and Python programs
> can be run within it.  However I wonder if it would be possible to
> somehow call individual python functions from Clojure.  Like I said, I
> have not tried this yet, so it might actually be straightforward and
> obvious.  I'm just wondering if anyone has tried doing this.

I haven't tried it, but the strategies for executing Jython code from
Java should work at least as well from Clojure. There are two
approaches.

One approach is to compile the Jython code into a class file. This
requires some work on the Python side (similar to using gen-class in
Clojure so that Clojure code can be called from Java), and the Python
class of interest can't use multiple-inheritance. This approach is
discussed in the section called "How to create Jython classes callable
from Java programs" at
http://www.seanet.com/~bugbee/python/jython4.html

Another approach is to invoke the Jython interpreter as you suggested,
load a Python script, and ask the interpreter to evaluate a function
for you. An example can be found in this page:
http://bytes.com/topic/python/answers/22390-executing-jython-function-java

Additional discussion about the second approach can be found in the
section called "How to run Python programs from Java" at
http://www.seanet.com/~bugbee/python/jython4.html

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Reply via email to