PEP 8
The official style guide for Python code, covering layout, naming and common idioms.
In more detail
The parts that matter most: four spaces per indentation level, snake_case for functions and variables, CapWords for classes, UPPER_CASE for constants, spaces around operators and lines kept reasonably short. A formatter applies most of it automatically.
Related terms
- code formatter — A tool that rewrites source code into a consistent layout, such as indentation and spacing, without changing what it does.
- linter — A tool that reads code or configuration without running it and flags likely mistakes and style problems.
- snake_case — Writing a multi-word name in lower case with underscores between words, as in tell_story, the Python standard for functions and variables.
- PEP — A Python Enhancement Proposal: a numbered design document describing a new feature, process or convention for Python.
Taught in
- Classes And Instances — Hands-on Python: Complete Video Course & Book
- Formatting, Linting And Style — Hands-on Python: Complete Video Course & Book
- Literals, Names And Four Number Bases — PCEP Certified Entry-Level Python Programmer (PCEP-30-02) Exam Prep
- When awk Runs Out: Python Data Types, Modules And Virtual Environments For Admins — CompTIA Linux+ (XK0-006) Exam Prep