Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Python: Python

MSDOS/Windows program files

 

 

Python python RSS feed   Index | Next | Previous | View Threaded


arundelo at mediaone

Aug 19, 2001, 12:25 AM

Post #1 of 5 (629 views)
Permalink
MSDOS/Windows program files

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.

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

Thank you for your help!

--Aaron Brown


peter at engcorp

Aug 19, 2001, 7:06 AM

Post #2 of 5 (581 views)
Permalink
MSDOS/Windows program files [In reply to]

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


arundelo at mediaone

Aug 19, 2001, 9:09 AM

Post #3 of 5 (571 views)
Permalink
MSDOS/Windows program files [In reply to]

Peter Hansen wrote:

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

You were right -- it was my code! The fact that the error
message caret always pointed to the last line of the program,
even if it was a comment, was just a symptom of an input
statement earlier in the program that looked like this:

input("Spam?"

So the interpreter was just waiting around for that trailing
parenthesis.

Your response inspired me to go through the program and
selectively comment everything out -- I felt pretty silly when I
found the mistake. Thanks for the help!

--Aaron


arundelo at mediaone

Aug 22, 2001, 9:02 AM

Post #4 of 5 (578 views)
Permalink
MSDOS/Windows program files [In reply to]

[.I already sent this in, and Peter got his cc, but for some
reason it apparently never appeared here on the newsgroup,
so here's another copy:]

Peter Hansen wrote:

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

You were right -- it was my code! The fact that the error
message caret always pointed to the last line of the program,
even if it was a comment, was just a symptom of an input
statement earlier in the program that looked like this:

input("Spam?"

So the interpreter was just waiting around for that trailing
parenthesis.

Your response inspired me to go through the program and
selectively comment everything out -- I felt pretty silly when I
found the mistake. Thanks for the help!

--Aaron


ralf.muschall at alphasat

Aug 23, 2001, 1:41 PM

Post #5 of 5 (574 views)
Permalink
MSDOS/Windows program files [In reply to]

"Aaron Brown" <arundelo [at] mediaone> writes:

> input("Spam?"
>
> So the interpreter was just waiting around for that trailing
> parenthesis.

A common trick to detect such bugs in languages without semantic
indenting is to reformat the whole source (C-x h C-M-\). All lines
below the error are then rightshifted, making the bad place stand out.

Is there any trick to do something like this automatically in Python?

Ralf

Python python RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.