Re: [Jython-users] call a java-method from embedded interpreter
by Diez B. Roggisch other posts by this author
Oct 13 2003 10:29AM messages near this date
[Jython-users] call a java-method from embedded interpreter
|
[Jython-users] Verify Script
Hi,
> interp = new PythonInterpreter();
> interp.set("obj1", obj);
> PyObject pyObject = interp.eval("obj1");
> pyObject.__getattr__("run").__call__(); <--- doesn't work?!
Why so complicated? Why don't you just do
PyObject pyObject = interp.eval("obj1.run()");
Yielding null here, you could go for "exec" of course.
Or just
obj.run()
- as you don't do anything "pythonic" there :)
I'm not sure why you get your error, but my guess is that its similar to what
you get when java reflection is used - you need pass the otherwise implicit
"this" argument explicitely. Use __call__(PyObject [] args), where the first
argument is supposed to be an instance of MyClass.
Diez
-------------------------------------------------------
This SF.net email is sponsored by: SF.net Giveback Program.
SourceForge.net hosts over 70,000 Open Source Projects.
See the people who have HELPED US provide better services:
Click here: http://sourceforge.net/supporters.php
_______________________________________________
Jython-users mailing list
Jython-users@[...].net
https://lists.sourceforge.net/lists/listinfo/jython-users
Thread:
Kay
Diez B. Roggisch
|