Skip to content

Instantly share code, notes, and snippets.

@habi
Created October 22, 2015 14:41
Show Gist options
  • Save habi/78132d37734861ae8d81 to your computer and use it in GitHub Desktop.
Save habi/78132d37734861ae8d81 to your computer and use it in GitHub Desktop.
import time
import numpy # not really needed for the printing, but for nice percentage :)
import sys
print 'Ciao Fede'
print 'Here is a percentage, on the same line'
for i in numpy.arange(0, 100, 0.1):
print '\r', # Comma is needed.
print 'Doing something. I am now %s%% done' % i, # Comma is needed
time.sleep(0.01)
sys.stdout.flush() # Might be needed depending on Python installation
print '\nThat was nice!' # We need to start a new line with the next 'print'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment