how to do *simple* syntax checking?
Preston Landers
prestonlanders at my-deja.com
Tue Nov 30 18:50:53 EST 1999
Okay, I know there was an earlier thread regarding pre-distribution
syntax checking (and the virtual impossibility of same).
I understand Python is a dynamicly typed language, and I have no real
need to be able to find previously undeclared names in code before I
run it.
However, it would be enormously helpful for me to be able to do
*simple* checks on Python code at make/'make install' time. Like
catching whitespace/indentation problems, missing semicolons, and the
like.
I maintain a large set of Python programs, some of which are accessed
through a CGI interface. I develop some code, run make install,
restart my web server (not always though) and then load up my URL.
Only to find "500 Internal Server Error."
Usually, if it's not a namespace issue, it's something silly like a
missing semicolon. But I have to track through the server logs to find
out what went wrong.
I thought that Python's compile() function would be what I want,
because I thought that the SyntaxError exception was thrown when making
bytecode. But that's not the case, unless I was notably un-thorough in
my investigation.
Basically, what I want is to do something like this for every Python
program in my makefile:
try:
simple_syntax_check("myfile.py")
except:
# file is no good, abort make process
# ... continue with make
Am I just dreaming? Is this unrealistic? Or is this kind of thing
fully availible and documented and I am just blind?
thanks,
---Preston
--
|| Preston Landers <prestonlanders at my-deja.com> ||
Sent via Deja.com http://www.deja.com/
Before you buy.
More information about the Python-list
mailing list