Modified Python example to use new error trapping.