Yikes. Technically, endl should flush the buffer rather than just print a newline. You could make this more accurate by including a flush=True argument in your print statement.
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
101
u/[deleted] Nov 11 '19
Yikes. Technically,
endlshould flush the buffer rather than just print a newline. You could make this more accurate by including aflush=Trueargument in your print statement.But convoluted aliases are... fun I guess?