# What is PEP 8?

PEP 8 establishes Python's official style guide for the Python code in its standard library, codifying the principles of writing readable, maintainable Python code.

While written specifically for the Python standard library, PEP 8 has often been used as a basis for code formatting in other projects.

## Key Aspects

### 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/classes
- One blank line between methods in classes

### Line Length
- Maximum line length of 79 characters for code
- Maximum line length of 72 characters for docstrings/comments

## Enforcing PEP 8

Modern Python projects rarely enforce PEP 8 manually. [Ruff](https://pydevtools.com/handbook/reference/ruff.md) handles both linting (catching PEP 8 violations via its pycodestyle rules) and formatting in a single tool. [Black](https://pydevtools.com/handbook/reference/black.md) is an older formatter that also enforces a PEP 8-compatible style. Both tools default to a line length of 88 characters rather than PEP 8's 79, a pragmatic choice that has become the community norm. See [How to configure recommended Ruff defaults](https://pydevtools.com/handbook/how-to/how-to-configure-recommended-ruff-defaults.md) for setup instructions.

## Learn More

- [PEP 8](https://peps.python.org/pep-0008/)
