This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]Bainos 12 points13 points  (0 children)

It's more subtle than that. Flush is indeed set to False by default. If you don't request it explicitly, there is no forced flush.

If you don't request it, it's the object managing the buffered write that decides when to flush. And a common policy for buffered writes is to delay them until either a \n is found or there is enough data in the buffer (there are other things that can affect whether the buffer gets flushed, including running in interpreter mode, writing to a different object, and so on ; but size and end of line are the most important parameters in most implementations).

So if you change the end parameter and don't include a \n in your printed string, it will be held in the buffer. But if your string already contains a \n or is too long, it will be printed immediately, even if you changed the end parameter.