Just Launched: You can now import projects and releases from Google Code onto SourceForge
We are excited to release new functionality to enable a 1-click import from Google Code onto the Allura platform on SourceForge. You can import tickets, wikis, source, releases, and more with a few simple steps. Read More
From: brian zimmer <bzimmer@zi...> - 2001-03-02 13:07:13
> hi..im trying to call the PythonInterpreter() from within a java app, and
> run a python program.Since Python does not have *native* support for
> interfaces, what can I do after importing a java interface? Also,when I
After importing an interface, you can build a class implementing it as if it
was a class.
def callme(self, somearg):
> import code from java that does use interfaces(for e.g. Vector implements
> List,Map etc),the following code
> from java.util import Vector
> throws an error TypeError: addElement(): expected 2 args; got 1
The reason you get the exception is because you are attempting to invoke the
method on the class Vector, rather than an instance of the class Vector.
You can fix this by:
>>> from java.util import Vector
>>> sim = Vector()
My guess is it's not that an object implements an interface but that you are
not creating instances of classes. In Java parlance, calling addElement as
you did above would work if addElement() was a static method.
> so what do I typecast the first argument to?
> gives TypeError: addElement(): self arg can't be coerced to (well, it
> doesnt say what...)
The self arg is automatically passed to the method when a method is invoked
on an instance, not the class.