Skip to content

Instantly share code, notes, and snippets.

View coljac's full-sized avatar
💭
Working hard

Colin Jacobs coljac

💭
Working hard
View GitHub Profile
@coljac
coljac / progbar.py
Created November 4, 2016 05:29
trivial progress bar example
def progbar(current, to, width=40, show=True):
percent = float(current)/float(to)
length = int( width * percent)
if show:
count = " (%d/%d) " % (current, to)
else:
count = ""
sys.stdout.write(("\r[" + ("#" * length).ljust(width) + "] %0d" % (percent*100)) + "%" + count)
sys.stdout.flush()