I have a Java application which calls some Python code. I have some problem in understanding how returning lists from Python to java.
Let's assume I have a very simple python module as follow:
def myFunc(param):
print param
return [ ["a","b"] , ["c","d"] , ["e","f"] ]
And a java piece of code that call this function:
String funcName = "myFunc";
try {
PythonInterpreter interpreter = new PythonInterpreter();
interpreter.exec("from myModule import * \n");
PyObject someFunc = interpreter.get(funcName);
someFunc.__call__(new PyString(workspacePath),new PyString(deployName));
}
catch(Exception e){
e.printStackTrace();
throw new Exception("Error while generating client resources.", e);
}
How can I transform the returned object to something that i can easily iterate over? How can I extract the string which are present in the list?
I tried messing around a bit with PyList or Iterable PyObject but with no success so far. Any idea?
Thanks
PyList pl = someFunc.__call__(etc)