Python snippets for useful functions