From: Andres Corrada-E. <co...@ci...> - 2001-10-19 15:16:19
|
Hello, Please bear with me. I'm new to Jython and want to use Python code in Java development environment. My attempt is failing because of a "instance already instantiated" error. I've simplified the rand.py code in www.jython.org to this: from java.util import Random class rand(Random): def __init__( self ): "@sig public rand()" # Random.__init__( self ) def nextDouble( self ): return Random.nextDouble( self ) I can use jythonc to turn this into a java class which I then use from a simple java file: import rand; class TestRand { public static void main(String args[]){ rand firstRand = new rand(); System.out.println( firstRand.nextDouble() ); } } As long as I do not call Random.__init__(self) in rand.__init__, the procedure works. But if I uncomment the line it fails with the "instance already instantiated" error. Since the actual Python class that I want to create needs to have something like, JavaSuperClass.__init__(self, foo) this commenting out of the line is not going to work for me. Any ideas on what I am doing wrong? I'm using Jython-2.0. on a SunOs machine. Andres Corrada-Emmanuel Senior Research Fellow Center for Intelligent Information Retrieval University of Massachusetts, Amherst |