''' Python 2.7 progress bar Code mostly taken from: https://stackoverflow.com/questions/3173320/text-progress-bar-in-the-console I usually use this for simple for loops with long iterations to make sure it's actually progressing without polluting stdout. ''' import sys n_iterations = 100 bar_len = 60 # Assuming the loop always starts from 0 for iterations_done in range(0, n_iterations): filled_len = int(round(bar_len * (iterations_done + 1) / float(n_iterations))) percents = round(100.0 * iterations_done / float(n_iterations), 1) bar = '=' * filled_len + '-' * (bar_len - filled_len) sys.stdout.write('[%s] %s%s, %d of %d\r' % (bar, percents, '%', iterations_done + 1, n_iterations)) sys.stdout.flush() # Do stuff here filled_len = bar_len percents = 100. bar = '=' * filled_len + '-' * (bar_len - filled_len) sys.stdout.write('[%s] %s%s \r' % (bar, percents, '%')) sys.stdout.flush()