PEP 8
PEP 8 is Python’s official style guide, authored by Guido van Rossum, Barry Warsaw, and Alyssa 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. Consistency with the style guide is important, but consistency within a project is more important, and consistency within a single module or function is the most important.
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 primary style reference for the Python community and helps create alignment around what Pythonic code looks like.
Developers typically enforce PEP 8 with automated tools, such as linters like flake8 or pylint and formatters like black or ruff format. Still, the style guide itself is tool-agnostic and focuses on human-readable principles rather than specific implementations.
Related Resources
Tutorial
How to Write Beautiful Python Code With PEP 8
Learn how to write readable, high-quality Python code by following the PEP 8 style guide and using linters and autoformatters to enforce it.
For additional information on related topics, take a look at the following resources:
- Writing Beautiful Pythonic Code With PEP 8 (Course)
- Python Code Quality: Best Practices and Tools (Tutorial)
- Writing Cleaner Python Code With PyLint (Course)
- Managing and Measuring Python Code Quality (Course)
- Write More Pythonic Code (Learning Path)
- How to Write Beautiful Python Code With PEP 8 (Quiz)
- Python Code Quality: Best Practices and Tools (Quiz)
Have a question about this? Mentor AI can show you examples, compare related terms, and point you to tutorials.
By Dan Bader • Updated Dec. 4, 2026