One way to get unbuffered output would be to use sys.stderrsys.stderr instead of sys.stdoutsys.stdout or to simply call sys.stdout.flush()sys.stdout.flush() to explicitly force a write to occur.
You could easily redirect everything printed by doing:
import sys; sys.stdout = sys.stderr
print "Hello World!"
import sys; sys.stdout = sys.stderr print "Hello World!" Or to redirect just for a particular printprint statement:
print >>sys.stderr, "Hello World!"
print >>sys.stderr, "Hello World!" To reset stdout you can just do:
sys.stdout =
sys.__stdout__
sys.stdout = sys.__stdout__