From: Jim A. <Ji...@do...> - 2001-10-19 17:26:20
|
For various reasons, I just use 'compile' directly: PyCode compiledPage = __builtin__.compile(pythonCode, showThisOnError, "exec"); Although I don't know if there's a way to 'optionally write out the .class' ?... > -----Original Message----- > From: Robert W. Bill [mailto:rb...@di...] > Sent: Thursday, October 18, 2001 7:45 PM > To: Max Muller > Cc: jyt...@li... > Subject: Re: [Jython-users] Creating a .class file from a .py > file from > inside a Java app > > > Hello Max, > > On Thu, 18 Oct 2001, Max Muller wrote: > > Hi, > > I have actually just recently gotten into jython, very cool > > I must say. I am right now in the process of writing a WebObjects > > framework that will allow for the use of Jython WOComponents. When > > it is done I'll release the source and make an annoucement on this > > list. Anyways, right now I have written a JythonClassLoader that > > when given the path to a .py file it will compile the file to a > > .class using jythonc and then read the .class in and construct the > > Class object. So what I am wondering is it possible to not use > > jythonc to compile the .class? I have been looking through > the api in > > the compiler package, but I haven't been able to find that magic > > method. What I would really like to be able to do is in my Java app > > read in the .py file and then using the Java api's of > jython, compile > > the .py file into a byte array (optionally write out the .class at > > this point) then construct the Class object, never having to fire up > > a process outside the regular vm. Anyone have any ideas? Thanks in > > advance. > > An embedded interpreter sounds ideal for your situation, if I've > understood everything correctly. You could execute a .py file in the > embedded interpreter, then retrieve the class defined in that > file as a > Java object with the interpreter's get method. A good > example of this is > the org.python.util.PyServlet class that comes with Jython. > > More embedding info found at http://www.jython.org/docs/embedding.html > > -robert > > > _______________________________________________ > Jython-users mailing list > Jyt...@li... > https://lists.sourceforge.net/lists/listinfo/jython-users > |