# What is PEP 8?

PEP 8 is a [Python Enhancement Proposal](https://pydevtools.com/handbook/explanation/pep.md) that defines the style guide for the Python standard library, written by Guido van Rossum in 2001. Technically scoped to the standard library, it became the basis for code style conventions across the ecosystem.

## Naming Conventions
- `snake_case` for functions and variables
- `PascalCase` for classes
- `UPPERCASE` for constants

## Whitespace Rules
- 4 spaces for indentation (no tabs)
- Two blank lines between top-level functions and classes
- One blank line between methods in a class

## Line Length

PEP 8 sets a maximum of 79 characters for code and 72 for docstrings and comments. That limit reflects the 80-column terminal standard of the early 2000s. Modern formatters like [Ruff](https://pydevtools.com/handbook/reference/ruff.md) and [Black](https://pydevtools.com/handbook/reference/black.md) default to 88 characters, a pragmatic adjustment that has become the community norm.

## Enforcing PEP 8

[Flake8](https://pydevtools.com/handbook/reference/flake8.md) was the dominant PEP 8 linter for over a decade. Most projects have moved to [Ruff](https://pydevtools.com/handbook/reference/ruff.md), which handles both linting (catching PEP 8 violations via its pycodestyle rules) and formatting in a single tool, running faster than Flake8. See [How to configure recommended Ruff defaults](https://pydevtools.com/handbook/how-to/how-to-configure-recommended-ruff-defaults.md) for setup, or [How to replace Black, isort, Flake8, and pyupgrade with Ruff](https://pydevtools.com/handbook/how-to/how-to-replace-black-isort-flake8-pyupgrade-with-ruff.md) to consolidate an existing linting stack.

## Learn More

- [PEP 8](https://peps.python.org/pep-0008/) covers indentation, naming, line length, and the rationale behind each rule
- [What is a PEP?](https://pydevtools.com/handbook/explanation/pep.md)
