From: Richard B. <ric...@wo...> - 2002-06-09 17:55:19
|
I got the book "Jython Essentials" and was beginning to work thru it. On page 57, I am getting multi-line errors in the interpreter for a simple loop example (see following). All works OK if code on single line. I quickly browsed the jython-users posts, but see no reference to similar problems. It appears the same error msg as Bug #222805 from 2000-11-18. I have tried this on NT4SP6 running Jython 2.1 ... and also on Win2000SP2. I quickly tried an older JDK 1.3 and got the same error msg. It seems I am doing something wrong or misunderstanding. Any suggestions? Thanx. --------- JYTHON INTERPRETER ----------- Jython 2.1 on java1.4.0 (JIT: null) Type "copyright", "credits" or "license" for more information. >>> for x in range(3): ... print x Traceback (innermost last): (no code object) at line 0 File "<console>", line 2 print x ^ SyntaxError: invalid syntax >>> for x in range(3): print x ... 0 1 2 >>> ------- RERUN EXAMPLES FROM BUG 222805 BELOW -------- >>> s = ( Traceback (innermost last): (no code object) at line 0 File "<console>", line 1 SyntaxError: invalid syntax >>> s = \ Traceback (innermost last): (no code object) at line 0 File "<console>", line 1 SyntaxError: invalid syntax >>> i = ( Traceback (innermost last): (no code object) at line 0 File "<console>", line 1 SyntaxError: invalid syntax >>> i = \ Traceback (innermost last): (no code object) at line 0 File "<console>", line 1 SyntaxError: invalid syntax >>> ------- BUG REQUEST ID 222805 --------- [ 222805 ] multi-line statements in the JPython interpreter Date: 2000-11-18 11:04 Priority: 1 Submitted By: Finn Bock (bckfnn) Assigned To: Nobody/Anonymous (nobody) Category: Core Status: Open Summary: multi-line statements in the JPython interpreter The following kinds of multi-line statements work if written in an imported module: s = ( 'Hello, world.' ) s = \ 'Hello, world.' i = ( 3+ 4 } i = \ 3 + 4 All of them fail in the JPython interpreter as soon as the first line is typed in. Is multi-line functionality supposed to be supported in the interactive interpreter? JPython 1.1beta2 on java1.2.1 Copyright (C) 1997-1999 Corporation for National Research Initiatives >>> >>> s = ( Traceback (innermost last): (no code object) at line 0 File "<console>", line 1 SyntaxError: invalid syntax >>> s = \ Traceback (innermost last): (no code object) at line 0 File "<console>", line 1 SyntaxError: invalid syntax >>> |
From: Noel R. <nr...@so...> - 2002-06-09 21:10:31
|
Noel Rappin wrote: > There's a known difference between Jython and CPython about multi-line > statements in the interpreter. In Jython Essentials, we mention it in > Appendix D, Jython and CPython differences. Essentially, you're > right, Jython does not allow multi-line funcitonality in the > interpreter. As to whether that's due to be fixed or not, I'm not > sure, you'd have to ask Finn or Samuele... > > Also, as somebody else pointed out, you do need to supply your own > indentation in the interpreter, the "..." prompt is only a signal that > you might be in a block, you still need to indent the block > consistently. As a side note, most of the examples in Jython > Essentials that don't have an interpreter prompt in front of them were > written in text files to be run non-interactively. The files are > available on-line at <http://examples.oreilly.com/jythoness/> > > Thanks, > > Noel Rappin > > Richard Boyd wrote: > >> I got the book "Jython Essentials" and was beginning to work thru it. >> On page 57, I am getting multi-line errors in the interpreter for a >> simple loop example (see following). >> All works OK if code on single line. >> I quickly browsed the jython-users posts, but see no reference to >> similar problems. >> It appears the same error msg as Bug #222805 from 2000-11-18. >> I have tried this on NT4SP6 running Jython 2.1 ... and also on >> Win2000SP2. >> I quickly tried an older JDK 1.3 and got the same error msg. >> It seems I am doing something wrong or misunderstanding. >> Any suggestions? >> Thanx. >> >> >> --------- JYTHON INTERPRETER ----------- >> >> Jython 2.1 on java1.4.0 (JIT: null) >> Type "copyright", "credits" or "license" for more information. >> >>> for x in range(3): >> ... print x >> Traceback (innermost last): >> (no code object) at line 0 >> File "<console>", line 2 >> print x >> ^ >> SyntaxError: invalid syntax >> >>> for x in range(3): print x >> ... >> 0 >> 1 >> 2 >> >>> >> >> >> ------- RERUN EXAMPLES FROM BUG 222805 BELOW -------- >> >> >>> s = ( >> Traceback (innermost last): >> (no code object) at line 0 >> File "<console>", line 1 >> SyntaxError: invalid syntax >> >>> s = \ >> Traceback (innermost last): >> (no code object) at line 0 >> File "<console>", line 1 >> SyntaxError: invalid syntax >> >>> i = ( >> Traceback (innermost last): >> (no code object) at line 0 >> File "<console>", line 1 >> SyntaxError: invalid syntax >> >>> i = \ >> Traceback (innermost last): >> (no code object) at line 0 >> File "<console>", line 1 >> SyntaxError: invalid syntax >> >>> >> >> >> ------- BUG REQUEST ID 222805 --------- >> >> [ 222805 ] multi-line statements in the JPython interpreter >> >> Date: >> 2000-11-18 11:04 >> Priority: >> 1 >> Submitted By: >> Finn Bock (bckfnn) >> Assigned To: >> Nobody/Anonymous (nobody) >> Category: >> Core >> Status: >> Open >> Summary: >> multi-line statements in the JPython interpreter >> The following kinds of multi-line statements work if written in >> an imported module: >> >> s = ( >> 'Hello, world.' >> ) >> >> s = \ >> 'Hello, world.' >> >> i = ( >> 3+ 4 >> } >> >> i = \ >> 3 + 4 >> >> All of them fail in the JPython interpreter as soon as the first line >> is typed >> in. >> >> Is multi-line functionality supposed to be supported in the interactive >> interpreter? >> >> JPython 1.1beta2 on java1.2.1 >> Copyright (C) 1997-1999 Corporation for National Research Initiatives >> >>> >> >>> s = ( >> Traceback (innermost last): >> (no code object) at line 0 >> File "<console>", line 1 >> SyntaxError: invalid syntax >> >>> s = \ >> Traceback (innermost last): >> (no code object) at line 0 >> File "<console>", line 1 >> SyntaxError: invalid syntax >> >>> >> >> >> _______________________________________________________________ >> >> Don't miss the 2002 Sprint PCS Application Developer's Conference >> August 25-28 in Las Vegas - >> http://devcon.sprintpcs.com/adp/index.cfm?source=osdntextlink >> >> _______________________________________________ >> Jython-users mailing list >> Jyt...@li... >> https://lists.sourceforge.net/lists/listinfo/jython-users > > > > |