i have a python file and want to check syntax error without compiling. I know about 'compileall', 'py_compile' but these all compile the code.
-
What are you using? IDE? Text editor? If you open the file in IDLE, you can use Run > Check Modulejonrsharpe– jonrsharpe2014-02-24 09:18:55 +00:00Commented Feb 24, 2014 at 9:18
-
I am using vi editor (linux) to write and run the file. I was lloking for command line option for the same.Bimlesh Sharma– Bimlesh Sharma2014-02-24 09:23:01 +00:00Commented Feb 24, 2014 at 9:23
-
Possible duplicate: stackoverflow.com/q/100298/1025391moooeeeep– moooeeeep2014-02-24 09:23:36 +00:00Commented Feb 24, 2014 at 9:23
Add a comment
|
1 Answer
So you'll need some static code analysis. There are several tools that can do so with Python:
Personally, I use Pylint. It is rather strict but with some minimal configuration you'll get quickly some useful feedback. It can be installed using pip:
pip install pylint
pylint <my_module>.py
There are some options to scan whole folders. Have a look at http://docs.pylint.org/run.html