Useful python code snippets