From Omnia
Jump to: navigation, search


Python Package Index : pep8 0.6.1 -

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

PEP 8 -- Style Guide for Python Code -

This document gives coding conventions for the Python code comprising the

standard library in the main Python distribution. Please see the companion informational PEP describing style guidelines for the C code in the C implementation of Python.

Apt Installation:

apt-get install pep8

pip install:

pip install pep8

Manual Installation:

mkdir -p ~/.src ; cd ~/.src
wget --no-check-certificate
tar -zvxf pep8-0.6.1.tar.gz
cd pep8-0.6.1
sudo python install  # requires setuptools

NOTE: Make sure to fix the '#!/usr/bin/python' in /opt/python26/bin/pep8 Executable:


Fix python version used:

sudo sed -i 's%#!/usr/bin/python%#!/usr/bin/env python%' /opt/python26/bin/pep8
NOTE: modify first line:
  #!/usr/bin/env python

Example usage:

$ pep8 E111 indentation is not a multiple of four E301 expected 1 blank line, found 0 E501 line too long (80 characters)


 -r, --repeat         show all occurrences of the same error
 --show-source        show source code for each error
 --show-pep8          show text of PEP 8 for each error

Ignore long lines:

pep8 --ignore E501


alias pep8="pep8 --ignore E501"

Change max line length to 120:

sudo sed -i 's/MAX_LINE_LENGTH = 79/MAX_LINE_LENGTH = 119/g' /opt/python27/lib/python2.7/site-packages/pep8-0.6.1-py2.7.egg/
# on other systems
sudo sed -i 's/MAX_LINE_LENGTH = 79/MAX_LINE_LENGTH = 119/g' usr/lib/python2.6/site-packages/