Using Pep8 and autopep8

PEP 8:

Pep8 is a tool to check your Python code against some of the style conventions in PEP 8.

For more info check this out:



You can install pep8 using pip

$ pip install pep8



Here you are checking the file to see if it has any errors. This will only give you the pep8 error and the line on which the error occurs. The ‘–first’ will only show you the first occurrence of each error.

$ pep8 –first


If you also want to see the code which has the error along with the pep8 error. The file is being checked.

$ pep8 –show-source –show-pep8 testsuite/



Autopep8 automatically formats Python code to conform to the PEP 8 style guide. Autopep8 is capable of fixing most of the formatting issues that can be reported by pep8. Also autoppep8 is awesome (USE IT!!!!!)


$ pip install autopep8


$autopep8 –in-place –aggressive –aggressive <filename>


-i, --in-place        make changes to files in place
-a, --aggressive      enable non-whitespace changes; multiple -a result in
                      more aggressive changes


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s