PEP 8
E256164
PEP 8 is the official Python style guide that defines conventions for writing readable, consistent Python code.
All labels observed (3)
| Label | Occurrences |
|---|---|
| PEP 8 canonical | 2 |
| PEP 8 style guidelines | 1 |
| PEP 8 – Style Guide for Python Code | 1 |
Statements (55)
| Predicate | Object |
|---|---|
| instanceOf |
Python Enhancement Proposal
ⓘ
style guide ⓘ |
| appliesTo | Python source code ⓘ |
| associatedWith | Python Software Foundation ⓘ |
| defines | coding style conventions for Python ⓘ |
| discourages |
extraneous whitespace before a colon
ⓘ
extraneous whitespace before a comma ⓘ extraneous whitespace before a semicolon ⓘ extraneous whitespace inside parentheses, brackets, or braces ⓘ multiple statements on one line ⓘ overly complex expressions ⓘ tab characters for indentation ⓘ trailing whitespace at the end of lines ⓘ using backslash for line continuation when parentheses can be used ⓘ using single-letter variable names except for counters ⓘ using wildcard imports ⓘ |
| influences | many Python projects' coding standards ⓘ |
| language | Python ⓘ |
| maintainer | Python core developers ⓘ |
| purpose |
to promote consistent Python code
ⓘ
to promote readable Python code ⓘ |
| recommends |
4 spaces per indentation level
ⓘ
UTF-8 as the default source encoding ⓘ grouping imports in standard library, third-party, and local order ⓘ imports at the top of the file ⓘ limiting the use of lambda expressions to simple functions ⓘ maximum line length of 72 characters for docstrings and comments ⓘ maximum line length of 79 characters for code ⓘ one import per line ⓘ using == and != for value comparisons ⓘ using CapWords (CamelCase) for class names ⓘ using English for comments and docstrings ⓘ using UPPER_CASE_WITH_UNDERSCORES for constants ⓘ using absolute imports when possible ⓘ using blank lines to separate logical sections of code ⓘ using blank lines to separate top-level function and class definitions ⓘ using cls as the first argument to class methods ⓘ using docstrings to document public modules, classes, methods, and functions ⓘ using explicit exception types instead of bare except ⓘ using explicit parentheses in complex boolean expressions ⓘ using if x is not None instead of if not x when checking for None ⓘ using is and is not for comparisons to None ⓘ using list comprehensions and generator expressions where appropriate ⓘ using lowercase_with_underscores for function names ⓘ using lowercase_with_underscores for variable names ⓘ using one space after colons in dictionaries ⓘ using one space after commas ⓘ using self as the first argument to instance methods ⓘ using spaces around binary operators ⓘ using with statements for resource management ⓘ |
| relatedTo |
Python code consistency
ⓘ
Python code readability ⓘ |
| status | Active ⓘ |
| title |
PEP 8
self-linksurface differs
ⓘ
surface form:
PEP 8 – Style Guide for Python Code
|
| usedBy | Python developers worldwide ⓘ |
Referenced by (4)
Full triples — surface form annotated when it differs from this entity's canonical label.
this entity surface form:
PEP 8 style guidelines
this entity surface form:
PEP 8 – Style Guide for Python Code