Useful snippets of python code