SyntaxError:unexpected EOF while eof怎么用parsing的翻译是:什么意思

compile() question: SyntaxError: unexpected EOF while parsing | Python | Python
this category
compile() question: SyntaxError: unexpected EOF while parsing
Jul&7,&&AM
Post #1 of 3
(1771 views)
compile() question: SyntaxError: unexpected EOF while parsing
While examining the core of medusa's monitor.py, we've encountered a situation that looks on the face of it like an undesirable limitation or inconsistency of the Python compiler.
(I fully expect to hear an explanation for why this is actually a Good Thing,
but we haven't figured it out ourselves yet.)
We expected the following two sequences to produce the same exception, but they do not.
&&& good = 'if 1:' &&& compile(good, '', 'exec') Traceback (most recent call last):
File "&stdin&", line 1, in ?
File "&string&", line 1
^ SyntaxError: unexpected EOF while parsing &&& bad = 'if 1:\n
print 1\nelse:' &&& compile(bad, '', 'exec') Traceback (most recent call last):
File "&stdin&", line 1, in ?
File "&string&", line 3
^ IndentationError: expected an indented block
Medusa's monitor.py uses the "unexpected EOF while parsing"
feature to infer that additional lines of text are going to be
entered by the user (to satisfy the expected indented block for
the "if").
This is how it knows when to deliver another "..."
prompt and when to cancel entry of data and deliver a real
exception.
Unfortunately this means when it or any code which tries to use the same technique encounters the beginning of the "else:" block, it terminates with the second exception.
(A workaround appears to be to precede everything with a dummy "if 1:" block, but I'm trying to learn why the
built-in compile() doesn't consistently produce the "unexpected EOF while parsing" message in the second case.)
---------------------- Peter Hansen, P.Eng. peter [at] engcorp
Jul&7,&&AM
Post #2 of 3
(1693 views)
compile() question: SyntaxError: unexpected EOF while parsing
[Peter Hansen] & While examining the core of medusa's monitor.py, we've encountered & a situation that looks on the face of it like an undesirable & limitation or inconsistency of the Python compiler.
(I fully expect & to hear an explanation for why this is actually a Good Thing, & but we haven't figured it out ourselves yet.)
Na, parser error msgs have a life of their own.
You can *try* to change one, but there's no guarantee it won't change back when you stop glaring at it &0.9 wink&.
& We expected the following two sequences to produce the same & exception, but they do not. & & &&& good = 'if 1:' & &&& compile(good, '', 'exec') & Traceback (most recent call last): &
File "&stdin&", line 1, in ? &
File "&string&", line 1 &
^ & SyntaxError: unexpected EOF while parsing & &&& bad = 'if 1:\n
print 1\nelse:' & &&& compile(bad, '', 'exec') & Traceback (most recent call last): &
File "&stdin&", line 1, in ? &
File "&string&", line 3 &
^ & IndentationError: expected an indented block & & & Medusa's monitor.py uses the "unexpected EOF while parsing" & feature to infer that additional lines of text are going to be & entered by the user (to satisfy the expected indented block for & the "if").
This is how it knows when to deliver another "..." & prompt and when to cancel entry of data and deliver a real & exception. & ...
Then it's not smart enough to handle Python code.
Code that is smart enough can be found in the std library module codeop.py, and people simulating interpreter loops should use the higher-level facilities in the std code.py. Getting this right in all cases is tricky (read the code); you've only bumped into one subtlety so far.
BTW, when reading the code, keep this in mind:
&&& issubclass(IndentationError, SyntaxError) 1 &&&
Jul&7,&&PM
Post #3 of 3
(1701 views)
compile() question: SyntaxError: unexpected EOF while parsing
Tim Peters wrote: &
& [Peter Hansen] & & Medusa's monitor.py uses the "unexpected EOF while parsing" & & feature to infer that additional lines of text are going to be & & entered by the user (to satisfy the expected indented block for & & the "if").
& Then it's not smart enough to handle Python code.
Code that is smart enough & can be found in the std library module codeop.py, and people simulating & interpreter loops should use the higher-level facilities in the std code.py. & Getting this right in all cases is tricky (read the code); you've only & bumped into one subtlety so far.
(That's a "good" damn :-)
This reminds me of the time I didn't have a handy-dandy 'cal' command at my DOS prompt.
I had an intuition that Python might help.
Without checking the docs, I tried "import calendar".
That worked.
"dir calendar" and a wild guess at "print calendar.calendar(2001)". I shouldn't be surprised at this kind of thing any more.
Isn't there *anything* not already done for us with Python?
(Thank you Tim, and may I say you have a charming and elegant last name? :)
---------------------- Peter Hansen, P.Eng. peter [at] engcorp
&&&&Announce
&&&&Python
&&&&Checkins
Interested in having your list archived?
Powered by Gossamer Threads Inc.unexpected eof while parsing meaning
... What is the date? ") File "&string&", line 0 ^ SyntaxError: unexpected EOF while parsing &&& Thanks in advance! ... Python unexpected EOF while parsing. 0./questions/5074225/python-unexpected-eof-while-parsingunexpected EOF while parsing error when taking input. ... SyntaxError: unexpected EOF while parsing ... but did not delete python 2 meaning my code was running .../questions//unexpected-eof-while-parsing-error-when-taking-input Python Syntax error: Unexpected EOF while parsing? ... unexpected EOF while parsing ... Python Syntax error: Unexpected EOF while parsing?/question/index?qid=59AAFZ2Uw... Unexpected EOF while parsing (parsing a dictionary) ... I mean, if I execute it one ... Python unexpected EOF while parsing 4./python/905247-python-unexpected-eof-while-parsing-parsing-dictionary.htmlSyntaxError: unexpected EOF while parsing. python. This question has already been answered. Start a new discussion instead. Message. Insert Code Snippet Alt+I./programming/software-development/threads/355483/cannot-resolve-syntaxerror-unexpected-eof-while-parsingUnexpected EOF while parsing... Discussion created by cfw2 on Sep 7, 2010 Latest reply on Sep 7, 2010 by Dan_Patterson. ... this row in the while loop of the script .../thread/96267What is an EOF error and how can i fix the problem? ... unexpected EOF while parsing" How do I fix this? ... EOF = "End of File"./questions/842334/what-is-an-eof-error-and-how-can-i-fix-the-problem.htmlSyntaxError: unexpected EOF while parsing, Noob question on Python . ... But I get this error message SyntaxError: unexpected EOF while parsing. What does that mean?https://forum.lowyat.net/topic/662517/allField Calculator Python Expression Issues. ... ERROR 000539: SyntaxError: unexpected EOF while parsing ... I am assuming you mean field value that needs changed .../questions/115039/field-calculator-python-expression-issuesEOF what does it mean? ... it says Unexpected token:,.(BCE0043) ... On line 60 it says expecting EOF found else Help!!@ var normalSpeed: .../questions/28838/eof-what-does-it-mean.html"Unexpected EOF error"? ... unexpected EOF while parsing (string, line 0) What does this mean and how do I fix it?/en/forum_questions/52cb7a1f631fe91f7e005da2unexpected EOF while looking for matching `"' - bash script. ... unexpected EOF while looking for matching `"' ./coding.sh: line 147: syntax error: unexpected end of file/questions/154427/unexpected-eof-while-looking-for-matching-bash-scriptUnexpected end of file while parsing Name has occurred. ... ?EURoeUnexpected end of file while parsing Name has ... Strange!! Unexpected end of file while parsing .../topic/c-sharp/answers/598007-strange-unexpected-end-file-while-parsing-name-has-occurredI m getting an error 'SyntaxError: unexpected EOF while parsing (&string&, line 0) ... Apache HTTP Server: What does this console warning from Django mean?/When-I-try-to-fetch-data-from-MSSQL-server-on-Django-I-m-getting-an-error-SyntaxError-unexpected-EOF-while-parsing-string-line-0-can-anyone-hel-on-thatPython 3.3 error: Unexpected Eof while parsing. ... the random section of the gains and losses and I keep running into unexpected eof while parsing error.https://ca./question/index?qid=57AABlndKAdvertising AdvertisingRelated searches
Our servicesWe supportOur toolsNeed help ?This website uses cookies to ensure you get the best experience on our website. Findeen - Copyright (C) 2013}

我要回帖

更多关于 while not rs.eof 的文章

更多推荐

版权声明:文章内容来源于网络,版权归原作者所有,如有侵权请点击这里与我们联系,我们将及时删除。

点击添加站长微信