Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@soeren
Created September 3, 2010 12:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save soeren/563805 to your computer and use it in GitHub Desktop.
Save soeren/563805 to your computer and use it in GitHub Desktop.
ScriptEngine engine = new ScriptEngineManager().getEngineByName("python");
engine.eval(new FileReader("foobar.py"));
Bindings bind = engine.getBindings(ScriptContext.ENGINE_SCOPE);
PyFunction func = (PyFunction) bind.get("func");
Foo foo = new Foo();
PyObject ret = func.__call__(Py.java2py(foo));
Bar bar = Py.tojava(ret, Bar.class);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment