Python Capture Output Of Function