Skip to content

Instantly share code, notes, and snippets.

@tai2
Last active October 6, 2015 14:28
Show Gist options
  • Save tai2/3006949 to your computer and use it in GitHub Desktop.
Save tai2/3006949 to your computer and use it in GitHub Desktop.
Display progress of work
#!/usr/bin/env python
import sys
import time
if __name__ == '__main__':
N = 100
for i in range(N):
time.sleep(1)
# http://en.wikipedia.org/wiki/ANSI_escape_code
print '\033[2K\033[0G%d/%d'%(i + 1, N), # ESC[u means restore current positon then ESC[K erase to the end
sys.stdout.flush()
print '\ndone'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment