From: Andres Corrada-E. <co...@ci...> - 2001-10-25 17:45:38
|
Hello, I have simplified my problem of accessing super class attributes to the following simple files-- Java super class: public class Foo { String outputTags; public Foo() { outputTags = new String("This is the Foo string!"); } } Python class that subclasses this Foo java class: import Foo class Bar(Foo): def __init__( self ): "Do nothing since jythonc will call Foo's constructor." pass def testAttributeCall( self ): "@sig public java.lang.String testAttributeCall()" return self.outputTags Java file to test jythonc's creation of Bar.class: import Bar; class TestAttribute { public static void main(String args[]){ Bar myBar = new Bar(); System.out.println( myBar.testAttributeCall() ); } } This fails with: AttributeError: instance of 'Bar' has no attribute 'outputTags'. The problem is also present if the Bar.py file is used (with an added Foo.__init__(self) call) from within Jython. So the question remains, how does one call super class attributes to avoid the AttributeError? Andres Corrada-Emmanuel Senior Research Fellow Center for Intelligent Information Retrieval University of Massachusetts, Amherst |