Why `print` content doesn't show immediately in terminal? [duplicate]

Solution 1:

How can I print the dots inline as it runs?

Try flushing your output, like so:

for _ in range(10):
    print '.',
    sys.stdout.flush()
    time.sleep(.2)  # or other time-consuming work

Or for Python 3.x:

for _ in range(10):
    print('.', end=' ', flush=True)
    time.sleep(.2)  # or other time-consuming work