1.PEP 8 and code formatters (Black, isort)
PEP 8 is Python's official style guide — spacing, naming, line length. Black and isort are tools that automatically reformat code to follow style rules, so a team never has to debate spacing or import order by hand.
Key features
- PEP 8 covers spacing, naming, line length (79 chars, teams often use 88-100), imports
- black reformats a file in place, with almost no configuration options by design
- isort sorts and groups import statements (stdlib, third-party, local) automatically
- black --check reports whether files WOULD change, without writing — used in CI
- A formatter has no opinion left to negotiate — running it twice makes no further changes
Formatters — what each one rewrites
- messy.py — unsorted imports, ragged spacing
- isort — sorts & groups imports only
- black — spacing, quotes, line breaks
Command
black myfile.py
isort myfile.py
# or, check without writing (for CI):
black --check myfile.pyPEP 8 is the style guide; black and isort enforce it automatically — run them before every commit so style is never a manual decision or a review debate.