Skip to content

Instantly share code, notes, and snippets.

@fanyang89
Created September 23, 2016 16:43
Show Gist options
  • Save fanyang89/0e5f9d1afdc04a356745056804f77d02 to your computer and use it in GitHub Desktop.
Save fanyang89/0e5f9d1afdc04a356745056804f77d02 to your computer and use it in GitHub Desktop.
Simple progress viewer for Python3
import sys
import time
def view(cond, duration):
progressBarChar = '-\|/'
pos = 0
while cond():
print(progressBarChar[pos], sep='', end='', flush=True)
pos = (pos + 1) % len(progressBarChar)
time.sleep(duration)
print('\b', sep='', end='')
if __name__ == '__main__':
view(lambda: True, 0.2)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment