From: John Y. <wo...@ec...> - 2002-02-09 05:36:20
|
quick question with embedding jython.... in the following example (from = the embedding 'tutorial' at jython.org) how do I access MyClass from within the python code? import org.python.util.PythonInterpreter;=20 import org.python.core.*;=20 public class SimpleEmbedded {=20 public static void main(String []args) throws PyException {=20 PythonInterpreter interp =3D new PythonInterpreter(); MyClass = MyObject =3D new MyClass(); // A class created by me System.out.println("Hello, brave new world"); interp.exec("import sys"); interp.exec("print sys"); // how do I do this? // = interp.exec("MyObject.doSomething()"); interp.set("a", new PyInteger(42)); interp.exec("print a"); interp.exec("x =3D 2+2"); PyObject x =3D interp.get("x"); System.out.println("x: "+x); System.out.println("Goodbye, cruel world"); } } class MyClass{ public void doSomething(){}} |