Okay, I figured out why this didn't work. Need to actually
call the function.
so "def func():\n\tprint 'hello'\nfunc()";
Nick
On Fri, Mar 30, 2001 at 02:36:43PM -0600, Nick Collier wrote:
> Hi,
>
> Can someone tell me why the code below doesn't print hello.
>
> public class EmbedTest {
>
> private String func = "def func():\n\tprint 'hello'";
>
> public void run() {
>
> // NullPointerException without creating an interpreter
> // need to initialize the runtime?
> // better way to do this?
> PythonInterpreter i = new PythonInterpreter();
> PyCode code = __builtin__.compile(func, "<string>", "exec");
>
> System.out.println(code.__class__);
> System.out.println(code.__dir__());
> System.out.println(code.__getattr__("co_argcount"));
> System.out.println(code.__getattr__("co_varnames"));
> PyStringMap locals = new PyStringMap();
>
> //Py.exec(code, locals, locals);
> Py.runCode(code, locals, locals);
> }
>
> public static void main(String[] args) {
> try {
> EmbedTest test = new EmbedTest();
> test.run();
> } catch (Exception ex) {
> ex.printStackTrace();
> }
> }
> }
>
> The compile call returns a PyTableCode object but the call to Py.runCode
> doesn't have any noticeable results.
>
> thanks,
>
> Nick
>
> --
> Nick Collier
> Social Science Research Computing
> University of Chicago
> http://repast.sourceforge.net
>
> _______________________________________________
> Jython-users mailing list
> Jyt...@li...
> http://lists.sourceforge.net/lists/listinfo/jython-users
--
Nick Collier
Social Science Research Computing
University of Chicago
http://repast.sourceforge.net
|