From: Andres Corrada-E. <co...@ci...> - 2001-10-18 15:18:31
|
Hello, I'm new to jython. I'm having problems creating a java class from python. I took the example in jython.org that subclasses java.util.Random into a python class: rand. If I then use jythonc to turn "rand" into a rand.class and use it in a java program I get an error with this traceback: at org.python.core.Py.TypeError(Py.java, Compiled Code) at org.python.core.PyReflectedConstructor.__call__(PyReflectedConstructor.java, Compiled Code) at org.python.core.PyReflectedConstructor.__call__(PyReflectedConstructor.java, Compiled Code) at org.python.core.PyReflectedConstructor.__call__(PyReflectedConstructor.java, Compiled Code) at org.python.core.PyObject.__call__(PyObject.java, Compiled Code) at rand$_PyInner.__init__$2(rand.java, Compiled Code) at rand$_PyInner.call_function(rand.java, Compiled Code) at org.python.core.PyTableCode.call(PyTableCode.java, Compiled Code) at org.python.core.PyTableCode.call(PyTableCode.java, Compiled Code) at org.python.core.PyTableCode.call(PyTableCode.java, Compiled Code) at org.python.core.PyFunction.__call__(PyFunction.java, Compiled Code) at org.python.core.PyInstance.__init__(PyInstance.java, Compiled Code) at org.python.core.Py.initProxy(Py.java, Compiled Code) at rand.<init>(rand.java, Compiled Code) at TestRand.main(TestRand.java, Compiled Code) Traceback (innermost last): File "~corrada/qa/test/rand.py", line 0, in __init__ TypeError: instance already instantiated for java.util.Random The rand.py is as shown in www.jython.org/docs/subclassing.html and my TestRand.java class looks like this: import rand; class TestRand { public static void main(String args[]){ rand firstRand = new rand(); System.out.println( firstRand.nextDouble() ); } } What am I doing wrong? Andres Corrada-Emmanuel Senior Research Fellow Center for Intelligent Information Retrieval University of Massachusetts, Amherst |