This post will try not to repeat Code Complete and PEP-8 and talk about Python specifically.
- Do NOT overwrite system’s python, unless you know what you’re doing: Gentoo user or have full backup.
- virtualenv per project, do not
sudo pip install, it’s like
using namespace std;+
.pycare imported prior to your new
.pyfiles with bugs fixed.
- Time complexity of common operations.
awesome-*projects are mostly bullshit : if you know what library/framework to choose, you don’t need them; if you don’t, you can’t distinguish good from bad ones(I’m not taking awesome-python personally) until you start using and reading others code.
pylint(and more) to check your code, a pre-commit hook could be overkill, but integrating them with CI should be trivial.
- Meta programming: jsondatabase shows good use of
__get__(though can’t really appreciate this silver bullet method)
- Pythonic code review introduces pythonic/convenient syntax like
namedtuple, and more importantly, what to focus when reviewing code.
- This post is a good summary.
- Gotchas are caused by too much expectations(why this does not work?!), try to have minimal expectations and write codes that you can understand and you’re sure they will work.
loggingmodule is your friend, read official document and some best practices: proper logging level,
__name__as logger name …
- Simple script can be debugged using
- line_profiler is by far the most intuitive profiling tool I’ve used.
- This article introduced segfaults handler, monitoring and more debugging tools.