Python Capture Output Of Functions