From: SourceForge.net <no...@so...> - 2007-06-27 04:55:26
|
Bugs item #1743933, was opened at 2007-06-26 19:22 Message generated for change (Comment added) made by cgroves You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=112867&aid=1743933&group_id=12867 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: Core Group: None >Status: Closed >Resolution: Invalid Priority: 5 Private: No Submitted By: Todd Cook (cookconsulting) Assigned to: Nobody/Anonymous (nobody) Summary: odd syntax bug Initial Comment: /* First time posting an error report here, so hope this helps. Otherwise, I love Jython! error detailed inline attached file from the PythonCookbook: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/298721/index_txt NOTE: the file works from the command prompt Python interpreter */ /** * User: tcook * Date: Jun 25, 2007 */ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.log4j.BasicConfigurator; import org.python.util.PythonInterpreter; import org.python.core.PyInteger; import org.python.core.PyObject; import org.python.core.PyString; import java.util.Properties; public class JythonTest { private static Log log = LogFactory.getLog(JythonTest.class); public static void main(String[] args) { try { // Set up a simple configuration that logs on the console. BasicConfigurator.configure(); System.out.println("Jython Test "); // to find modules, they must be pushed into the path Properties props = new Properties(); props.setProperty("python.path", "/users/tcook/Documents/pythonScripts/"); PythonInterpreter.initialize(System.getProperties(), props, new String[]{""}); PythonInterpreter interp = new PythonInterpreter(); try { interp.exec ( "import xml2obj2 as xml2obj" ) ; /// xml2obj2.py exists in /users/tcook/Documents/pythonScripts/ //error is: // Jython Test // Traceback (innermost last): // File "<string>", line 1, in ? // File "/users/tcook/Documents/pythonScripts/xml2obj2.py", line 138 // yield oChild // ^ // SyntaxError: invalid syntax // other stuff was planned, but it blows up... // note other programs and evaluation work in this same setup.... } catch (Exception e) { e.printStackTrace(); } } catch (Exception e) { log.error(e); } } } ---------------------------------------------------------------------- >Comment By: Charles Groves (cgroves) Date: 2007-06-26 23:55 Message: Logged In: YES user_id=1174327 Originator: NO The syntax error is because the program is using the 'yield' keyword to make a generator, which didn't appear until Python 2.3. It's available in Jython 2.2 but only if you add 'from __future__ import generators' as the first line of the file. Just pop that in there and the syntax error will go away. ---------------------------------------------------------------------- Comment By: Todd Cook (cookconsulting) Date: 2007-06-26 19:33 Message: Logged In: YES user_id=211366 Originator: YES This is regarding: Jython 2.2 RC1! my system version is: Python 2.3.5 (#1, Jan 13 2006, 20:13:11) ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=112867&aid=1743933&group_id=12867 |