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()
