PEP 8

PEP 8 is Python’s official style guide, authored by Guido van Rossum, Barry Warsaw, and Nick Coghlan. It outlines coding conventions for writing clear, readable Python code that’s consistent with the core Python codebase. PEP 8 can be read online in the Python Enhancement Proposal (PEP) database at peps.python.org/pep-0008 or at pep8.org.

PEP 8 emphasizes readability and consistency. Its fundamental guidelines state that code is read much more often than it’s written, and consistency within a project is more important than personal style preferences.

Created in 2001, PEP 8 has evolved through Python’s development while maintaining its core principles. While not all Python code follows PEP 8 strictly, it remains the definitive style reference for the Python community.

Developers typically enforce PEP 8 through automated tools (linters) like flake8, pylint, or black, though the style guide itself is tool-agnostic and focuses on human-readable principles rather than specific implementations.

Tutorial

How to Write Beautiful Python Code With PEP 8

Learn how to write high-quality, readable code by using the Python style guidelines laid out in PEP 8. Following these guidelines helps you make a great impression when sharing your work with potential employers and collaborators.

intermediate best-practices

For additional information on related topics, take a look at the following resources:


By Dan Bader • Updated Jan. 8, 2025