Installing and running pylint

Not sure if you have seen my post around Pylint and now I have the obsession around fixing my code.

To be able to install pylint, this is very simple to install. As you can imagine the quickest, easiest option is by using pip.

pip install pylint

Now you are ready, all you need to do now is point this at a script to see how compliant you are

pylint fantastic_code.py

Now here I will put some examples of how you can write PEP8 compliant code, may help you get a head start on your code before using pylint. You may already be using some of these and be in a better place. For me I always use two space, this is a no-no and should be 4 spaces.

So some quick PEP8 rules etc.

  • 4 spaces as indent

  • Continuation lines must line up with variable start. (example below)

  • spaces over tabs

  • Limit lines to 79 characters

  • Imports on separate lines

  • Two Blank lines between functions

  • Constants - ALL CAPS

  • modules - short, lowercase name

  • functions - lowercase with underscores

Continuation line example

foo = long_function_name (variable_one,
                         variable_two)

Please get in touch if you have any questions or want some more information, add a comment or send me an email.





Quick Tips for Notion

See lines before or after when matching with grep