PEP 8
PronunciationPEP AYT
Definition
PEP 8 is Python's official style guide. It describes how to name things, indent and format code so Python programs look consistent.
Where you hear it
In Python code reviews, linter and formatter settings, and onboarding documents for new developers.
Examples
Please follow PEP 8: four spaces and
snake_casenames.The linter reports a PEP 8 violation on that line.
PEP 8 asks for two blank lines before a top-level class.
Common mistake
Arguing about style by hand in reviews. Let a formatter such as Ruff or Black enforce it automatically.
Don't confuse with
A linter, which finds likely bugs. PEP 8 is only the style agreement the tools check.
Say it at work
- In a meeting or chat
Run the formatter so we don't discuss PEP 8 in the review.
- In an email or ticket
The CI fails on style, so fix the PEP 8 warnings first.
Keep exploring
More in Programming Fundamentals