Perl has the -c
switch to compile the code without running it. This is convenient for debugging compile errors in Perl.
Does Python have a similar switch?
Perl has the -c
switch to compile the code without running it. This is convenient for debugging compile errors in Perl.
Does Python have a similar switch?
You can say
python -m py_compile script_to_check.py
However, this will have the side effect of creating a compiled script_to_check.pyc
file in the same directory as your script. This feature is designed to speed up later uses of a module rather than to make sure that your syntax is correct, though you could certainly use it for that.
Through 2.6, there's the compiler package. That page doesn't say if there is a replacement in 3.0, or if you just can't do that any more.