started adapting the ruby example to python