All I'm trying to do is pass an argument to the python interpreter so it can be passed as an argument for a module.
E.g. I have the following defined in a py file:
def print_twice(test):
print test
print test
I want to pass it the argument "Adam", so I've tried:
// Create an instance of the PythonInterpreter
PythonInterpreter interp = new PythonInterpreter();
// The exec() method executes strings of code
interp.exec("import sys");
interp.exec("print sys");
PyCode pyTest = interp.compile("Adam", "C:/Users/Adam/workspace/JythonTest/printTwice.py");
System.out.println(pyTest.toString());
I've also tried:
interp.eval("print_twice('Adam')");
I've been using the following Jython API but I don't understand it well: http://www.jython.org/javadoc/org/python/util/PythonInterpreter.html#compile%28java.lang.String,%20java.lang.String%29
I would be very grateful for your advices.
Thank you