Skip to content

Instantly share code, notes, and snippets.

@ducu
Created January 13, 2016 21:35
Show Gist options
  • Save ducu/45247abf1662fdb50ecf to your computer and use it in GitHub Desktop.
Save ducu/45247abf1662fdb50ecf to your computer and use it in GitHub Desktop.
Progress
import sys, time
def chunks(l, n):
c = len(l)
for i in xrange(0, c, n):
sys.stdout.write("\r%d%%" % (min(i+n,c)*100/c,))
sys.stdout.flush()
yield l[i:i+n]
for chunk in chunks(range(100), 10):
time.sleep(1)
print ''
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment