Steve Howell <[EMAIL PROTECTED]> wrote: > > --- Jeremy C B Nicoll <[EMAIL PROTECTED]> wrote: > > > Steve Howell <[EMAIL PROTECTED]> wrote: > > > > > --- Jeremy C B Nicoll <[EMAIL PROTECTED]> > > wrote: > > > > > > What command (in XP) does one need to issue to syntax check a saved > > > > python script without running it? > > > > > > Perhaps oversimplifying a bit, running "python" does a syntax check, > > > and if it passes, moves on the next steps of interpretation/execution. > > > > Ah, I've been using IDLE so far (but would probably prefer to write > > Python in my normal text editor). In IDLE Alt-X syntax checks the saved > > copy of the file being edited (at least it seems to), and I was > > wondering how to replicate that elsewhere. > > What's your normal text editor? You might want try googling to see if it > has a Python mode. Also, look into seeing if it has a way to > automatically invoke external programs.
Mansfield Software's Kedit, but that's not the problem. You said that running python does a syntax check and then goes on to run the program. I would want to replicate IDLE's check process which syntax checks a program and then, even if it is ok, doesn't go on to run it. I see nothing on the python.exe CLI options that offers that. The only way I can think of doing it is to copy the file to be syntax-checked to a temporary file (presumably in the same directory though, or search paths won't be right) and append a line with a guaranteed syntax error in it, then ask python to 'execute' the dummy file. If the original file was ok then it will fail the syntax check on the final deliberate-error line, whereas, obviously any other syntax error is a genuine one. But that seems a crazy way to go about things. -- Jeremy C B Nicoll - my opinions are my own. -- http://mail.python.org/mailman/listinfo/python-list