-
-
Save mrtazz/451191 to your computer and use it in GitHub Desktop.
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 progressbar(it, prefix = "", size = 60): | |
count = len(it) | |
def _show(_i): | |
x = int(size*_i/count) | |
sys.stdout.write("%s[%s>%s] %i/%i\r" % (prefix, "="*x, "-"*(size-x), _i, count)) | |
sys.stdout.flush() | |
_show(0) | |
for i, item in enumerate(it): | |
yield item | |
_show(i+1) | |
sys.stdout.write("\n") | |
sys.stdout.flush() | |
for i in progressbar(range(15), "Computing: ", 40): | |
time.sleep(0.1) # long computation |
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
Computing: [........................................] 0/15 | |
... | |
Computing: [########................................] 3/15 | |
... | |
Computing: [########################################] 15/15 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment