Redirecting STDOUT to a Python Variable

Anthony Papillion papillion at gmail.com
Tue Jun 22 02:10:56 EDT 2010


I'm writing an application that uses the Google Storage Python
library.  When an error occurs, the error is printed on the terminal.
What I need to do is intercept that text into a variable so I can run
a re.search() against it and find out what's going on.

I thought doing a output_text = method_name(parameters) would stuff
the output in the output_text variable but it doesn't.

How can I accomplish this?



More information about the Python-list mailing list