By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,360 Members | 3,011 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,360 IT Pros & Developers. It's quick & easy.

Finding "hidden" syntax errors

P: n/a
It doesn't happen often, but once in a while I will
introduce a syntax error into a Python program I'm
working on (in IDLE) and doing File-Check responds
with the expected "Failed to check, syntax error -
invalid syntax". The problem is where the cursor
stops is perfectly legal syntax. I then begin
going through the laborious job of cutting out
pieces of the code until I find what is wrong. Is
there some easier way of doing this. I tried
pychecker but got nowhere because it said it
couldn't import (which I'm sure is because of the
syntax error). Does anyone out there have a "better"
way of tracking down these difficult to locate
errors?

Thanks in advance for any hints.

Regards,
Larry Bates
Syscon, Inc.

Jul 18 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Hello Larry,
I tried pychecker but got nowhere because it said it couldn't import
(which I'm sure is because of the syntax error). Does anyone out there
have a "better" way of tracking down these difficult to locate errors?

I'm using pychecker. It says where the error is:
--- syn.py ---
def f(x):
if x = 2: # Syntax error
print "YO"
else:
print "Halt! Who goes there?"
--- syn.py ---

[10:45] $pychecker syn.py
Processing syn...
SyntaxError: invalid syntax (syn.py, line 2)
if x = 2: # Syntax error
^

Warnings...

syn:1: NOT PROCESSED UNABLE TO IMPORT
[10:45] $

pychecker found out that the problem is in line 2.

Maybe some concrete example?

Bye.
--
-------------------------------------------------------------------------
Miki Tebeka <mi*********@zoran.com>
The only difference between children and adults is the price of the toys.

Jul 18 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.