Catching console output to string?
Moshe Zadka
moshez at math.huji.ac.il
Wed Nov 1 09:58:58 EST 2000
On Wed, 1 Nov 2000, Robert Brotherus wrote:
> Thank you for your help!
>
> At least in the Python environment, I got your proposed idea working. The
> code:
>
> import sys
> print "Starting........."
>
> class StringWriter:
> def __init__(self):
> self.x = ""
> def write(self, text):
> self.x += text
You forget one thing: Python coes with batteries included.
StringWriter can be replaced with StringIO/cStringIO.
More information about the Python-list
mailing list