Indentation & Spacing
4 spaces per indent | Use spaces, not tabs |
max 79 chars per line | Line length limit (79 for code, 72 for docs) |
2 blank lines around top-level defs | Functions/classes |
1 blank line between methods | Inside class |
space after comma: f(a, b, c) | Function arguments |
Naming Conventions
snake_case | Variables, functions, modules |
CapWords / PascalCase | Classes |
ALL_CAPS | Constants |
_private | Private by convention |
__dunder__ | Magic/dunder methods |
Import Order
1. stdlib imports | e.g. os, sys, json |
2. third-party | e.g. requests, django |
3. local imports | e.g. from . import utils |
blank line between groups | Separate each group |
from x import y (avoid import *) | Explicit imports |