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


Question

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?

1
326
3/6/2016 11:35:19 AM

Accepted Answer

You can check the syntax by compiling it:

python -m py_compile script.py
534
12/8/2011 10:57:30 PM

You can use these tools:


Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow
Icon