compile() question: SyntaxError: unexpected EOF while parsing

Peter Hansen peter at
Sun Jul 8 06:53:18 CEST 2001

Tim Peters wrote:
> [Peter Hansen]
> > Medusa's 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, and people simulating
> interpreter loops should use the higher-level facilities in the std
> Getting this right in all cases is tricky (read the code); you've only
> bumped into one subtlety so far.

Damn!  (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.  Then 
"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?  Damn!

(Thank you Tim, and may I say you have a charming and elegant last name? :)

Peter Hansen, P.Eng.
peter at

More information about the Python-list mailing list