Last modified: August 22, 2022
General formatting and coding
- Python uses spaces, in fact use 4-space indentation, and no tabs.
- Wrap lines so that they don’t exceed 79 characters.
- Use blank lines to separate functions and classes, and larger blocks of code inside functions.
- Generally: use
PascaleCasefor class names and
snake_casefor functions and method defs. Always use
selfas the name for the first argument of class methods.
- Use docstrings.
- Use spaces around operators and after commas, but not directly inside bracketing constructs: a = f(1, 2) + g(3, 4).