From: Nick C. <ni...@sr...> - 2001-03-30 20:35:21
|
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 |