Sal
Peter Hoffmann Director Data Engineering at Blue Yonder. Python Developer, Conference Speaker, Mountaineer

Python file interface for strings

This my Answer to the stackoverflow question: Python file interface for strings:

Yes, there is StringIO:

import StringIO
import sys


sys.stdout = StringIO.StringIO()
print "foo", "bar", "baz"
s = sys.stdout.getvalue()