snippets from python cookbook