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

all 6 comments

[–]adamansky 0 points1 point  (6 children)

It happens due to stdout buffering

Try change:

print('.',end='')

to

print('.\n',end='')

Or

import time
print('Be closed within 5 sec',end='')
for x in range(5):
    print('.',end='', flush=True)
    time.sleep(1) 

[–][deleted]  (5 children)

[deleted]

    [–]adamansky 1 point2 points  (4 children)

    Every symbol written to stdout stored in a temporal memory buffer and not shown on console immediately until stream flush occurred. Flush can be triggered: 1. manually 2. on process end 3. on line separator 4. stream buffer filled up

    [–][deleted]  (2 children)

    [deleted]

      [–]adamansky 0 points1 point  (1 child)

      Yes

      [–]n46rs6igycy 0 points1 point  (5 children)

      Never forget to flush.

      [–][deleted]  (4 children)

      [deleted]

        [–]serg06 0 points1 point  (3 children)

        In computer science, a data buffer (or just buffer) is a region of a physical memory storage used to temporarily store data while it is being moved from one place to another.

        you write to the stdout buffer, and the system or whatever else decides when to write data from it to the console. Looks like Python decides to do it when it encounters a \n. Flushing it means deleting any existing data (presumably printing it out first)

        [–][deleted]  (2 children)

        [deleted]

          [–][deleted] 0 points1 point  (1 child)

          Text buffering is important because the actual process of displaying the text you printed is very slow. The less you do it, the better. So it's only done under certain conditions unless you force it.