ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> Jython-users
Jython-users
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

Privacy Policy | Email Opt-out | Feedback | Syndication
© ActiveState Software Inc. All rights reserved