Skip to content

How to ensure your python code to match style guide pep8

ulfmueller edited this page Jun 25, 2018 · 2 revisions

Preface

Pep8 is a python style guide, which aims to use a uniform standard layout for python programs. This increases the readability and comparability for other developers. Please take note of the documentation for an extended description.

Work flow

We suggest to use the pypi package pep8 to check your python code regarding the pep8 style guide. The installation of this package can be done inside the terminal by pip install pep8. Afterwards you run the package on your code via pep8 Input.py, which gives you remarks to code lines with exceptions to the pep8 style guide directly on your screen. pep8 Input.py > Output generates an output file for the exceptions. As last step your code has to be adapted with respect to the named exceptions.

autopep8

It is possible to automatically formats Python code to conform to the PEP 8 style guide. https://pypi.org/project/autopep8/

Clone this wiki locally