PEP 8

GPTKB entity

Statements (53)
Predicate Object
gptkbp:instanceOf Python Enhancement Proposal
gptkbp:appliesTo gptkb:Python_programming_language
gptkbp:author gptkb:Guido_van_Rossum
gptkb:Barry_Warsaw
gptkb:Nick_Coghlan
gptkbp:created 2001-07-05
gptkbp:describes coding conventions for Python
https://www.w3.org/2000/01/rdf-schema#label PEP 8
gptkbp:influenced Python code formatters
Python community coding standards
Python linters
gptkbp:recommendation Use lowercase_with_underscores for function and variable names
4 spaces per indentation level
Use docstrings to describe all public modules, functions, classes, and methods
Use docstrings for all public modules, functions, classes, and methods
Avoid extraneous whitespace
Avoid global variables
Avoid trailing whitespace
Avoid using bare except
Surround method definitions inside a class with a single blank line
Limit lines to 79 characters
Use == to compare values
Use CapWords for class names
Use UTF-8 encoding
Use absolute imports
Use blank lines to separate functions and classes
Use block comments to explain code
Use cls as the first argument to class methods
Use consistent naming conventions
Use explicit exception names
Use inline comments sparingly
Use is to compare identities
Use list comprehensions where appropriate
Use parentheses for multi-line expressions
Use self as the first argument to instance methods
Use spaces after commas, colons, and semicolons
Use spaces around operators
Surround top-level function and class definitions with two blank lines
Use underscores to improve readability of large numbers
Use is not and not is instead of not ... is and not ... is not
Avoid using lambda expressions for complex functions
gptkbp:section Code layout
Comments
Imports
Naming conventions
Programming recommendations
Whitespace in expressions and statements
gptkbp:status Active
gptkbp:title gptkb:PEP_8_–_Style_Guide_for_Python_Code
gptkbp:topic Python code style
gptkbp:url https://peps.python.org/pep-0008/
gptkbp:bfsParent gptkb:Python
gptkbp:bfsLayer 5