Created
September 23, 2016 16:43
-
-
Save fanyang89/0e5f9d1afdc04a356745056804f77d02 to your computer and use it in GitHub Desktop.
Simple progress viewer for Python3
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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