python redirect stdout to function