What is PEP 8?

Beginner

Answer

PEP 8 is the official style guide for Python code. It provides conventions for:

  • Indentation: Use 4 spaces per indentation level
  • Line length: Maximum 79 characters
  • Naming conventions: snake_case for variables, UPPER_CASE for constants
  • Import organization: Standard library, third-party, local imports
  • Whitespace: Proper spacing around operators and after commas