PEP8 Rules
http://legacy.python.org/dev/peps/pep-0008/
- Imports are at the top.
- Import one library on each line.
- Two newlines between top level functions & classes.
- One newline between methods and sub-classes.
- Indentation space should be 4.
- A space after every comma, colon and semicolon.
- A space around operators.
- No spaces around operators inside function parentheses.
- No spaces after parentheses.
- Function arguments should also be divided by spaces.
- Function long arguments should be on multiple lines and in a block.
- Don’t use letters for variables.
- Variable & function names should be lowercase and separated by underscores.
- Class names are capitalized.
Flake8
Flake8 will check your code if it matches PEP8 standards and fish for any violations
flake8 app.py
PEP20: The Zen of Python
- Beautiful is better than ugly.
- Explicit is better than implicit.
- Simple is better than complex.
- Complex is better than complicated.
- Flat is better than nested.
- Sparse is better than dense.
- Readability counts.
- Special cases aren’t special enough to break the rules.
- Although practicality beats purity.
- Errors should never pass silently.
- Unless explicitly silenced.
- In the face of ambiguity, refuse the temptation to guess.
- There should be one– and preferably only one –obvious way to do it.
- Although that way may not be obvious at first unless you’re Dutch.
- Now is better than never.
- Although never is often better than *right* now.
- If the implementation is hard to explain, it’s a bad idea.
- If the implementation is easy to explain, it may be a good idea.
- Namespaces are one honking great idea — let’s do more of those!