import time
for i in range(100):
time.sleep(0.1)
print("sleeping is happening")
I think it will print the string every 0.1 seconds, but actually it prints the string 100 times on the output client after the code is done.
The answer is a little different (python version 3.5):
following is not useful
import sys
sys.stdout.flush()
and
print("sleeping is happening", flush = True)
is corret.