Indentation
- Use 4 spaces per indentation level.
Suggested Maximum Line Length
- Limit all lines to a maximum of 79 characters. Feel free to ignore if inconvenient.
Blank Lines
- Blank lines must have the same indentation level as the immediately following non-blank line. This is an exception to the "No trailing whitespace" rule.
Whitespace in Expressions and Statements
Avoid extraneous whitespace in the following situations:
- Immediately inside parentheses, brackets or braces.
Yes: spam(ham[1], {eggs: 2})
No: spam( ham[ 1 ], { eggs: 2 } )
- Between a trailing comma and a following close parenthesis.
Yes: foo = (0,)
No: bar = (0, )
- Immediately before a comma, semicolon, or colon:
Yes: if x == 4: print x, y; x, y = y, x
No: if x == 4 : print x , y ; x , y = y , x
- Immediately before the open parenthesis that starts the argument list of a function call:
Yes: spam(1)
No: spam (1)
- Immediately before the open parenthesis that starts an indexing or slicing:
Yes: dct['key'] = lst[index]
No: dct ['key'] = lst [index]
x = 1
y = 2
long_variable = 3
x = 1
y = 2
long_variable = 3
For everything else you might think of, refer to PEP8 as completely optional style advice except where it contradicts the above.
Indentation
Suggested Maximum Line Length
Blank Lines
Whitespace in Expressions and Statements
Avoid extraneous whitespace in the following situations:
More than one space around an assignment (or other) operator to align it with another.
Yes:
For everything else you might think of, refer to PEP8 as completely optional style advice except where it contradicts the above.