Skip to content

Instantly share code, notes, and snippets.

@lennax
Created July 22, 2012 22:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lennax/3161269 to your computer and use it in GitHub Desktop.
Save lennax/3161269 to your computer and use it in GitHub Desktop.
Updating a single printed line
#!/usr/bin/python
import sys
import time
spinner = ["-", "\\", "|", "/"]
print "This is the header row"
try:
for i in range(10):
sys.stdout.flush()
sys.stdout.write("\r%s %2d%%" % (spinner[i%4], i))
time.sleep(1)
except KeyboardInterrupt:
pass
print
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment