Skip to content

Instantly share code, notes, and snippets.

@lovasoa
Created June 5, 2017 17:50
Show Gist options
  • Save lovasoa/d5d77d3b7577e9dc81352fd5d0c63fe6 to your computer and use it in GitHub Desktop.
Save lovasoa/d5d77d3b7577e9dc81352fd5d0c63fe6 to your computer and use it in GitHub Desktop.
ipython progressbar iterator: show a progressbar for loops inside ipython
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