python redirect stdout to string