Pylint

Pylint is a tool that checks for errors in Python code, tries to enforce a coding standard and looks for refactoring opportunities. It is very good at flagging areas of your code that deserve a second look for possible errors or clean-up.

While Pylint can be run from the command line, it is much more convenient in an IDE. The IDE that I use for this is Spyder IDE. It is available on all major platforms, see: Install Spyder. For other IDEs with integrated Pylint go to http://www.pylint.org/.

When you run Pylint, remember that what it recommends is not to be taken as gospel. It may warn you about things that you have conscientiously done. Don’t be afraid to disable Pylint warnings that you have thought about and determined to be spurious. For example the following comment in a python source file:

# pylint: disable=C0321

will disable the pylint warning message C0321 (“more than one statement on a single line”).

In my opinion, the greatest benefit of Pylint is to simply draw your attention to a questionable piece of code and make you think about it. Each disable comment is a testament to the fact that your judgment is better than some rigid set of guidelines.

Check out Pylint Documentation for further documentation.