eugene y eugene y - 2 years ago 91
Python Question

How can I check the syntax of Python script without executing it?

I used to use

perl -c programfile
to check the syntax of a Perl program and then exit without executing it. Is there an equivalent way to do this for a Python script?

Answer Source

You can check the syntax by compiling it:

python -m py_compile
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download