Python switch for syntax checking

Ian Bicking ianb at colorstudy.com
Fri Nov 19 16:20:41 EST 2004


Jeff Duffy wrote:
> Hi all.
> 
>  I've been wondering why python itself doesn't provide a switch to check 
> a file for valid syntax. I know that you can currently call
> 
> python -c "import py_compile; py_compile.compile(r'MyApp.py')"

If you look at the py_compile module, if it's run as a script it will 
compile any filenames you pass to it, so you should be able to do:

   python /path/to/py_compile.py MyApp.py

And with Python 2.4 I think it will be:

   python -m py_compile MyApp.py

-- 
Ian Bicking  /  ianb at colorstudy.com  /  http://blog.ianbicking.org



More information about the Python-list mailing list