import time
print 1
time.sleep(5)
I ran the code above in IPython notebook and normal script separately.
In IPython Notebook
, it doesn't print the number '1' until time.sleep(5)
is finished, while in normal script it DOES print out number '1' first and go into time.sleep(5)
. What would that happen?
This example is just to illustrate my problem: I use print
to print out some text at every stage in my code, which takes a long time to finish, so that I can know where the programme has got to. I found this works fine when executing the script, but in IPython Notebook
print
often lags behind and everything is printed out when the whole program is finished.
Is there any way to solve this in IPython Notebook
?