@Test public void testList() throws Exception { PythonVariables pyInputs = new PythonVariables(); PythonVariables pyOutputs = new PythonVariables(); Object[] x = new Object[]{1L, 2L, 3L, "a", "b", "c"}; Object[] y = new Object[]{4L, 5L, 6L, "d", "e", "f"}; pyInputs.addList("x", x); pyInputs.addList("y", y); String code = "z = x + y"; pyOutputs.addList("z"); Python.exec(code, pyInputs, pyOutputs); Object[] z = pyOutputs.getListValue("z").toArray(); Assert.assertEquals(z.length, x.length + y.length); for (int i = 0; i < x.length; i++) { if (x[i] instanceof Number) { Number xNum = (Number) x[i]; Number zNum = (Number) z[i]; Assert.assertEquals(xNum.intValue(), zNum.intValue()); } else { Assert.assertEquals(x[i], z[i]); } } for (int i = 0; i < y.length; i++) { if (y[i] instanceof Number) { Number yNum = (Number) y[i]; Number zNum = (Number) z[x.length + i]; Assert.assertEquals(yNum.intValue(), zNum.intValue()); } else { Assert.assertEquals(y[i], z[x.length + i]); } } }
public static void exec(String code) throws PythonException { simpleExec(getWrappedCode(code)); throwIfExecutionFailed(); }
PythonExecutioner { public static void exec(String code) throws PythonException { simpleExec(getWrappedCode(code)); throwIfExecutionFailed(); } }
PythonExecutioner { public static void exec(String code) throws PythonException { simpleExec(getWrappedCode(code)); throwIfExecutionFailed(); }  }
PythonExecutioner { public static void exec(String code) throws PythonException { simpleExec(getWrappedCode(code)); throwIfExecutionFailed(); }  static boolean validateVariableName(String s); static void setVariable(String varName, PythonObject pythonObject); static void setVariable(String varName, PythonType varType, Object value); static void setVariables(PythonVariables pyVars); static PythonObject getVariable(String varName); static T getVariable(String varName, PythonType<T> varType); static void getVariables(PythonVariables pyVars); static void exec(String code); static void exec(String code, PythonVariables inputVariables, PythonVariables outputVariables); static PythonVariables execAndReturnAllVariables(String code); static PythonVariables getAllVariables(); static PythonVariables execAndReturnAllVariables(String code, PythonVariables inputs); static synchronized void initPythonPath(); }
PythonExecutioner { public static void exec(String code) throws PythonException { simpleExec(getWrappedCode(code)); throwIfExecutionFailed(); }  static boolean validateVariableName(String s); static void setVariable(String varName, PythonObject pythonObject); static void setVariable(String varName, PythonType varType, Object value); static void setVariables(PythonVariables pyVars); static PythonObject getVariable(String varName); static T getVariable(String varName, PythonType<T> varType); static void getVariables(PythonVariables pyVars); static void exec(String code); static void exec(String code, PythonVariables inputVariables, PythonVariables outputVariables); static PythonVariables execAndReturnAllVariables(String code); static PythonVariables getAllVariables(); static PythonVariables execAndReturnAllVariables(String code, PythonVariables inputs); static synchronized void initPythonPath(); final static String DEFAULT_PYTHON_PATH_PROPERTY; final static String JAVACPP_PYTHON_APPEND_TYPE; final static String DEFAULT_APPEND_TYPE; }