Python Cookbook sample code