Since we had this discussion I've been using Jython in Clojure and I've been growing a little library to make things easier. I decided it was useful enough to make live (though probably far from complete, seeing as my use case has been solely on one python library, nltk).
http://code.google.com/p/clojure-python/source/browse/trunk/ http://code.google.com/p/clojure-python/source/browse/trunk/src/python.clj Let me know what you think, feedback, suggestions, contributions, etc. Rob On Jan 25, 6:31 pm, rob <r.p.l...@gmail.com> wrote: > Thanks again Marc, I made a note of it on the StackOverflow thread. > > On Jan 25, 2:41 pm, Marc Downie <m...@openendedgroup.com> wrote: > > > > > On Mon, Jan 25, 2010 at 5:34 PM, rob <r.p.l...@gmail.com> wrote: > > > Thank you for these good ideas! I'm going to try it. My goal is to > > > use the Natural Language Toolkit inClojure. I also posted the same > > > question here: > > >http://stackoverflow.com/questions/2129253/clojure-jython-interop > > > Since NLTK is variously just bunch functions, or classes without any java > > interface counterpart (because it's a pure Python library, it doesn't know > > anything about Java), I'm afraid you really are looking at the kind of > > things that I wrote in my first email. (The leading answer on stackoverflow > > seems technically correct, but misses the Py.java2py and .__tojava__ > > convenience calls, and has a go at to recoding part of them inClojure). > > > have fun (and do let me know when you come up with something tighter than > > what I wrote). > > > best, > > > Marc. > > > > Rob > > > > On Jan 24, 7:08 pm, Eric Lavigne <lavigne.e...@gmail.com> wrote: > > > > > I was wondering if anyone has tried somehow callingJythonfunctions > > > > > from withinClojure, and how you went about doing this if so. I have > > > > > not usedJython, but I would imagine theJythoninterpreter 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 fromClojure. 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 executingJythoncode from > > > > Java should work at least as well fromClojure. There are two > > > > approaches. > > > > > One approach is to compile theJythoncode into a class file. This > > > > requires some work on the Python side (similar to using gen-class in > > > >Clojureso thatClojurecode 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 createJythonclasses callable > > > > from Java programs" athttp://www.seanet.com/~bugbee/python/jython4.html > > > > > Another approach is to invoke theJythoninterpreter 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... > > > > > Additional discussion about the second approach can be found in the > > > > section called "How to run Python programs from Java" athttp:// > > >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 tocloj...@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<clojure%2bunsubscr...@googlegroups.com > > > > > > > For more options, visit this group at > > >http://groups.google.com/group/clojure?hl=en -- 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