Read PEP 8, Style Guide for Python Code on the official Python website.

"PEP" stands for "Python Enhancement Proposal." PEPs are circulated in the Python community to communicate ideas or proposed changes to the Python language, though some are purely informative. (These are similar to the Internet Engineering Task Force's Requests For Comment or RFCs.)

PEP 8, "Style Guide for Python Code," is an informative PEP by Guido van Rossum and Barry Warsaw that lays down guidelines for Python programmers to follow when formatting their code. By and large, they are conventions designed to make Python code more consistent and understandable by programmers. Such consistency is especially important when code is shared as freely as it is in the open-source world. It also helps avoid common mistakes that may lead to subtle, hard-to-find bugs.

As such, many projects and programmers use PEP 8 (or a slight modification) as the golden stylebook for writing python code. There are however exceptions to this observation, for instance in cases where a python library is a wrapper of native python implementation of a non-python library/toolkit and must maintain API compability.

A variety of syntax checkers for python arose to check for adherence to the PEP 8 guidelines. Pylint follows by default the rules set forth by this PEP, but has built-in capabilities for modification of those rules.

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License