misc useful bits of python code