What is PEP 8?
Assesses fundamental understanding of Python conventions, runtime behavior, and memory/performance considerations.
Hiring managers look for precision, avoidance of ambiguous jargon, and ability to explain trade-offs under real production conditions.
PEP 8 (Python Enhancement Proposal 8) is the official style guide for writing clean, readable, and maintainable Python code, authored in 2001 by Guido van Rossum, Barry Warsaw, and Nick Coghlan.
### Core PEP 8 Conventions:
- Indentation: Use 4 spaces per indentation level. Never mix tabs and spaces.
- Line Length: Limit lines to a maximum of 79 characters (or 88 characters under modern tools like Black).
- Naming Conventions:
snake_casefor functions, methods, and variable names (calculate_total).PascalCase(CamelCase) for class names (UserAccountManager).UPPER_SNAKE_CASEfor module-level constants (MAX_RETRY_COUNT = 3).- Leading underscore
_protected_memberfor internal APIs.
- Imports: Place all imports at the top of the file, grouped in three distinct blocks separated by single blank lines:
- Standard library imports
- Third-party package imports
- Local application/library imports
- Modern Automation: Rather than checking PEP 8 manually, modern teams enforce it via automated linters and formatters such as Ruff, Flake8, and Black in CI/CD pipelines.
Candidate Response Strategy & Interview Tips
- Start with a concise one-sentence summary: Deliver a direct, confident answer first before expanding into nuances.
- Demonstrate real-world trade-offs: Discuss where this approach excels and when you would avoid it in production systems.
- Discuss complexity & edge cases: Proactively explain time/space complexity or boundary conditions (null values, scale limits).
- Prepare for interviewer follow-ups: Technical hiring panels frequently probe deeper into concurrency, backward compatibility, or alternative libraries.