From: Andres Corrada-E. <co...@ci...> - 2001-10-23 13:32:41
|
Apparently the answer is no if you plan to turn that python class back into a java class. Is this a bug or am I not getting how to turn python classes into java classes? I have the following python class that subclasses from java.util.Random. It's a modification of the rand.py code shown in the jython website: rand.py: from java.util import Random class rand(Random): def __init__( self ): "@sig public rand()" Random.__init__( self ) def nextDouble( self ): return Random.nextDouble( self ) This is turned into a java class with jythonc. It is tested with this java file: TestRand.java: import rand; class TestRand { public static void main(String args[]){ rand firstRand = new rand(); System.out.println( firstRand.nextDouble() ); } } Executing this java file leads to an "instance already instantiated" error. If this sounds familiar to you maybe you've read my previous two emails to the list on this problem. Nobody seems to care :-( The code works if you take Random.__init__(self) out of rand.py. But this means you cannot call the super class constructor within your own init. This sucks! It must be something I'm doing wrong because the website explicitly mentions that you CAN call the super class constructor. Please, please, please help me out of my quagmire. I'm dying to use Python and if this doesn't work for me I'll be condemned to writing Java code. Andres Corrada-Emmanuel Senior Research Fellow Center for Intelligent Information Retrieval University of Massachusetts, Amherst |