android python full integration
Posted
by
Grzegorz Oledzki
on Stack Overflow
See other posts from Stack Overflow
or by Grzegorz Oledzki
Published on 2011-01-09T20:37:10Z
Indexed on
2011/01/09
20:53 UTC
Read the original article
Hit count: 315
Is there a way to fully integrate Python with Java code on Android platform?
Yes, I saw the question about running Python on Android and Android Scripting Environment (ASE).
But that doesn't seem to be enough (correct me if I am wrong). I wanted to be able not only to invoke a Python script from within Java code, but have a full integration. The feature I need the most is the ability to have a state of execution of python code saved and be able to run several parts of code on demand against the same execution state.
On JavaSE I would rely on Jython. I believe its simplest example shows it all (and some other features too, like something I would call variable state introspection):
http://www.jython.org/archive/21/docs/embedding.html
PythonInterpreter interp = new PythonInterpreter();
System.out.println("Hello, brave new world");
interp.exec("import sys");
interp.exec("print sys");
interp.set("a", new PyInteger(42));
interp.exec("print a");
interp.exec("x = 2+2");
PyObject x = interp.get("x");
System.out.println("x: "+x);
System.out.println("Goodbye, cruel world");
Is it possible on Android? Is ASE a way to go?
© Stack Overflow or respective owner