Useful python code