python - printing items inline in IPython -


i need print inline dynamically in loop in ipython notebook. using python 2.7. used code:

for in xrange(10):    print "." ,     #some computation , no print statement 

and used:

for in xrange(10):    print "\b."    #some computation , no print statement 

but both of above solutions doesn't seem work in ipython notebooks.

what need is: .......... , above snippets printing is:

. . . . . . . . . . 

any , every appreciated.

this work on both python 2 , python 3:

from __future__ import print_function  in range(10):     print('.', end='') 

you can pass flush=true keyword argument force flush buffer instantly.

you can overwrite previous line using '\r', her's simple example:

import time  in range(10):     time.sleep(0.2)     print('\r{} / 10'.format(i + 1, 10), end='') 

Comments

Popular posts from this blog

ios - RestKit 0.20 — CoreData: error: Failed to call designated initializer on NSManagedObject class (again) -

java - Digest auth with Spring Security using javaconfig -

laravel - PDOException in Connector.php line 55: SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES) -