hello, On Thu, Apr 28, 2011 at 01:20:16PM +0200, Ervin Hegedüs wrote: > #!/usr/bin/python > > import a > import b > > import sys > import StringIO > > output = StringIO.StringIO() > > def c(): > # save default stdout > tout = sys.stdout > # redirect stdout to StringIO object > sys.stdout = output > # a.a() prints their output to StringIO object > a.a() > # back up default stdout > sys.stdout = tout > # print StringIO object value > print "retval:", output.getvalue() > > c()
sorry, this is a littlebit more abstact example, it gives a StringIO object, instead of write to a file - of course, you can do what you want with that string... a. -- http://mail.python.org/mailman/listinfo/python-list