I was reading about std.flush() in python. And I found this example a lot.
import sys,time for i in range(10): print i, #sys.stdout.flush() time.sleep(1) It is often said that it makes a difference with/without the "sys.stdout.flush()". However, when I called this script from command prompt, it didn't make a difference in my case. Both printed numbers to the screen in real time. I used python 2.7.5 in windows.
Why is that happening?
p.s. In another example which printed the output through subprocess.PIPE instead of to the screen directly, I did observe a difference of the buffering.
What am I missing?
flushis simply a way to guarantee that the output buffer is flushed at that particular moment in time, but it may be flushed automatically by the OS even without callingflushexplicitly.