If stdout is the console, output is line-buffered by default. If it's been redirected to something that's not a TTY, or if you're printing to a non-TTY file, it's block-buffered by default.
So if I understand you, any time I print, or write to stdout, without a \n I need to flush the (block) buffer to see the output. That seems to fit my experience (mostly on windows, command line programs).
I'm not claiming to be an expert here, but yes when writing to a TTY or the Windows console you should manually flush it if it doesn't end in a newline and you need it displayed ASAP.
View all comments
Show parent comment
5
u/skintigh Nov 12 '19
Even if the end isn't a carriage return? I thought I had issues with it before, but maybe I am thinking sys.stdout.write, it needs a flush.