I forget where I originally found this and Google on my phone was unhelpful.
My favorite annoying trick is x -=- 1
. It looks like it shouldn’t work because that’s not precisely a valid operator, but it functions as an increment equivalent to x += 1
It works because -=
still functions are “subtract and assign”, but the second minus applies to the 1 making it -1.
If you’re on Linux (or Mac), add an alias to your .bashrc:
alias activate="source env/bin/activate"
Now you can activate your venv by just running activate
in the project root!
If using pyenv to support multiple python versions, when creating venvs, make sure to pass --copies
to it.
% python3 -m venv venv --copies
Ordinarily, venv uses symbolic links back to the current version of the python binary. A lot of tools and IDEs don’t traverse symbolic links. That flag actually copies the real binaries over to the venv.
This avoids a metric ton of hard-to-diagnose misery later on.
import antigravity