Fernando RodrÃguez wrote: > How can I temporarely redirect stdout to a string? > Use the StringIO module: >>> import sys, StringIO >>> print 1 1 >>> stdold, stdnew = sys.stdout, StringIO.StringIO() >>> sys.stdout = stdnew >>> print 2 >>> sys.stdout = stdold >>> print 3 3 >>> stdnew.getvalue() '2\012' >>> -Steve -- Steve Purcell, Pythangelist Get testing at http://pyunit.sourceforge.net/ Any opinions expressed herein are my own and not necessarily those of Yahoo
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4