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 s
Perhaps useful online checker PEP8 : http://pep8online.com/
Thanks to the above answers @Rosh Oxymoron. I improved the script to scan all files in a dir that are python files. So for us lazy folks just give it the directory and it will scan all the files in that directory that are python.
import sys
import glob, os
os.chdir(sys.argv[1])
for file in glob.glob("*.py"):
source = open(file, 'r').read() + '\n'
compile(source, file, 'exec')
Save this as checker.py and run python checker.py ~/YOURDirectoryTOCHECK