Created
June 5, 2017 17:50
-
-
Save lovasoa/d5d77d3b7577e9dc81352fd5d0c63fe6 to your computer and use it in GitHub Desktop.
ipython progressbar iterator: show a progressbar for loops inside ipython
This file contains hidden or 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
from IPython.html.widgets import FloatProgressWidget | |
from IPython.display import display | |
def display_progress(collection): | |
""" | |
>>> l = [1,2,3] | |
>>> for e in display_progress(l): do_something(e) | |
""" | |
f = FloatProgressWidget(min=0, max=len(collection)) | |
display(f) | |
for element in collection: | |
f.value += 1 | |
yield element |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment