MSDOS/Windows program files

Peter Hansen peter at engcorp.com
Sun Aug 19 10:06:15 EDT 2001


Aaron Brown wrote:
> I'm running Python 2.1.1 on Win98.  (My Linux box is down for
> repairs.)  When I save and run a program file I get "SyntaxError:
> invalid syntax" on whatever the last line happens to be, even if it's
> a comment.  I assume that Python does not like whatever
> end-of-file character is being put there, but interactive mode
> reacts properly to ctrl-z.

Maybe that's a bad assumption.  Why not post your code?

> It happens no matter whether I use EDIT or Notepad to create
> the file.

Neither EDIT nor Notepad append a Ctrl-Z to the end of a file,
and in fact both show it when you edit the file and allow it to
be removed...

Furthermore Python doesn't seem to mind the Ctrl-Z other than 
that it treats it as end-of-file and ignores anything that
comes after it (on Windows).  It doesn't generate a SyntaxError 
on my machine with any number of test files I just tried.

I can't reproduce your problem with any experiments I've
tried, so I think your assumptions might be wrong.
(Doesn't SyntaxError always point to the erroneous code
with a little caret symbol ^ ?  Post your error message!)

-- 
----------------------
Peter Hansen, P.Eng.
peter at engcorp.com



More information about the Python-list mailing list