[Jython] Generated Java file doesn't extend base class?
sismex01 at hebmex.com
sismex01 at hebmex.com
Mon Dec 16 15:26:45 EST 2002
More information about the Python-list mailing list
Mon Dec 16 15:26:45 EST 2002
- Previous message (by thread): Simple Gui for Data entry...
- Next message (by thread): [Jython] Generated Java file doesn't extend base class?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
> From: skywalkerpackage at hotmail.com > Sent: Monday, December 16, 2002 2:08 PM > > Hello all, > > I try to create Java class files from Python for a Java Agents > Environment (Grasshopper, see www.ikv.de). I use Jython for this task. > > In order to create a minimal Grasshopper mobile agent you just have to > extend de.ikv.grasshopper.agent.MobileAgent and to overwrite the > live() methode. This looks as follows in Java: > > // sample file HelloAgent.java > import de.ikv.grasshopper.agent.MobileAgent; > > public class HelloAgent extends MobileAgent { > public void live() { > log("Hello Agent!"); > } > } > > Therfore, I thought the equivalent Python code would look like this: > > # HelloAgent.py > from de.ikv.grasshopper.agent import MobileAgent > > class HelloAgent(de.ikv.grasshopper.agent.MobileAgent): > def live(self): > "@sig public void live()" > log("Hello Agent!") > > > > > I don't get a compilation error, but it doesn't work because the > generated Java file (HelloAgent.java) extends java.lang.Object and not > de.ikv.grasshopper.agent.MobileAgent > > Why? Can't I force jythonc to generate a Java file that extends > de.ikv.grasshopper.MobileAgent? EOW. You're extending the wrong identifier; when you do: > from de.ikv.grasshopper.agent import MobileAgent the identifier "MobileAgent" is brought into your namespace, there's no need to use "de.ikv.grasshopper.agent.MobileAgent", because you didn't import the whole module, only a single identifier from within. I know I shouldn't say this, but reading the docs will help you. > > Any help would be great. > > ByeBye > > Johannes > -- > http://mail.python.org/mailman/listinfo/python-list >
- Previous message (by thread): Simple Gui for Data entry...
- Next message (by thread): [Jython] Generated Java file doesn't extend base class?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list