Compile without execute for syntax check?
breiter at usf.Uni-Osnabrueck.DE
Tue Mar 7 15:35:19 CET 2000
The python interpreter in the non inspecting mode(default) finds
some python syntax errors directly before running the code.
Call me old fashioned, but the documentation is not clear about how
to use this build-in syntax check on scripts without executing them.
Nothing in the FAQ ether.
Yes, I should be able to do an
which can degenerate into
python -c "import py_compile; py_compile.compile('myscript.py')"
and might create python bytecode files.
And pythonwin of course has this as a nice button upfront.
So why nothing in the python manpage (where I looked first) in the
FAQ (second) look or in the library documentation?
The answer seems obvious: Just make everything a module then you can
compile it and run the test function in the same moment within
actually doing harm. This is certainly a healthy attitude, but
sometimes I do not want to run a testfunction, I just want the
syntax checked. :)
ps.: Do I gain speed if I execute script, which I compiled with
py_compile, like "python myscript.pyc" instead of "python myscript.py"?
Free Software Projects and Consulting (intevation.net)
Association for a Free Informational Infrastructure (ffii.org)
More information about the Python-list