In my Java app I want to use Jython to interpret Python code.
So I initialise Jython as follows:
PySystemState.initialize();
PythonInterpreter jython = new PythonInterpreter();
Then I want to test it like this:
jython.eval("out = ''");
jython.eval("out += 'Test1\n'");
jython.eval("out += 'Test2\n'");
System.out.println(jython.get("out").toString());
However, the first eval line throws this error:
File "<string>", line 1
out = ''
^
SyntaxError: mismatched input '=' expecting EOF
When I try it with exec instead of eval I get this error:
File "<string>", line 2
'
^
SyntaxError: no viable alternative at character '''
Any ideas what I am doing wrong here?
PS: I am using jython-2.5.4-rc1