From: <Mat...@i2...> - 2001-10-01 20:30:58
|
How do I run a piece of frozen python script within an embedded jython interpreter? i.e. How do I get the following contrived example to work? Foo.py: class Foo: def __init__(self, blah): self.blah = blah def doSomething(): blah.doSomethingElse() Foo.py is precompiled to Foo.class using jythonc, PyObject f = new Foo(); // how do I call __init__ with arguments? PythonInterpreter interp = new PythonInterpreter(); interp.set("foo", f); interp.exec("foo.doSomething()"); Alternatively, how would I bytecompile a script, and pass the code object to the interpreter? I tried to use jythonc to create a class file, and then used that as a source for an InputStream to PythonInterpreter.exexfile(), but that just gave me syntax errors on the binary data at runtime. I guess it needs to be a python byte compiled file instead...? bar.py: print "hello world" print "bye world" How do I bytecompile bar.py? how do I then load and run the bytecompiled bar.py using a PythonInterpreter instance? Any help appreciated, thanks, Matt mat...@i2... |