This is a draft cheat sheet. It is a work in progress and is not finished yet.
General Rules
4 spaces for identation |
Maximum line length 79 characters |
Line break before binary operators |
Content order: Module comments, docstrings, imports, module globals, constants |
Naming conventions
Package / Module |
lowercase |
Class |
CamelCase |
Variables |
CamelCase |
Global Variables |
lowercase_underscore |
Functions / Methods |
lowercase_underscore |
private Methods / Instance Variables |
Leading _ and then lowercase_underscore |
Constants |
UPPERCASE_UNDERSCORE |
Blank lines
Surround top-level functions and class definitions with two blank lines. |
Surround Method definitions inside a class by a single blank line. |
Extra blank lines may be used (sparingly) to separate groups of related functions. |
Use blank lines in functions, sparingly, to indicate logical sections. |
Imports
Imports should usually be on separate lines |
Imports should be grouped in the following order: 1.standard library imports 2.related third party imports 3. local application/library specific imports You should put a blank line between each group of imports. |
Wildcard imports (from <module> import *)
should be avoided |
|
|
|