From: Leo U. <leo...@ya...> - 2006-12-04 21:34:41
|
blows up in Jython and Python for me. :) leouser --- Neil Benn <nei...@zi...> wrote: > Hello, > > I am trying to evaluate a script which > runs as follows > (using both BSF and JYthonInterp does the same > thing): > > --- > > String strScript = "def test():\n"; > strScript += "\treturn 1\n"; > strScript += "test()"; > > Object objResult = objInterp.eval(strScript); > > --- > > However I get the following traceback (this is when > run from > JythonInterp), I've snipped the bottom bit off > because it is in the unit > test code > > Traceback (innermost last): > (no code object) at line 0 > SyntaxError: ('invalid syntax', ('<string>', 1, 1, > 'def test():')) > > at > org.python.core.parser.fixParseError(parser.java) > at > org.python.core.parser.parse(parser.java) > at > org.python.core.Py.compile_flags(Py.java) > at > org.python.core.Py.compile_flags(Py.java) > at > org.python.core.__builtin__.eval(__builtin__.java) > at > org.python.core.__builtin__.eval(__builtin__.java) > > at > org.python.util.PythonInterpreter.eval(PythonInterpreter.java) > at > uk.co.ziath.datapaq.server.scripting.JythonScriptProcessor.evaluateScrip > t(JythonScriptProcessor.java:76) > at > uk.co.ziath.datapaq.server.scripting.test.JythonScriptProcessorTest.test > MethodJythonScript(JythonScriptProcessorTest.java:75) > <snip> > > --- > > When I attempt to run a simple script > such as 3* 4 and > evaluate it, I get back 12 as I would expect. > However it seems that any > multi-line script fails on me. Is it true that I > cannot use a > multi-line script in an evaluate statement (I know I > can do it in an > execute statement)? > > Thanks for your help. > > Cheers, > > Neil > > > --- > Neil Benn > CEO Ziath Ltd > http://www.ziath.com > > > ------------------------------------------------------------------------- > Take Surveys. Earn Cash. Influence the Future of IT > Join SourceForge.net's Techsay panel and you'll get > the chance to share your > opinions on IT & business topics through brief > surveys - and earn cash > http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV> _______________________________________________ > Jython-users mailing list > Jyt...@li... > https://lists.sourceforge.net/lists/listinfo/jython-users > ____________________________________________________________________________________ Do you Yahoo!? Everyone is raving about the all-new Yahoo! Mail beta. http://new.mail.yahoo.com |