#############################
Migrated to http://pythonadventures.wordpress.com/2010/09/27/autoflush/.
import sys
import os
# reopen stdout file descriptor with write mode
# and 0 as the buffer size (unbuffered)
sys.stdout = os.fdopen(sys.stdout.fileno(), 'w', 0)
print "unbuffered text"
This tip is from http://www.gossamer-threads.com/lists/python/python/658167 .