Skip to content

Instantly share code, notes, and snippets.

@pipermerriam
Created May 8, 2014 16:42
Show Gist options
  • Select an option

  • Save pipermerriam/d02f97a8b2b6f0a000be to your computer and use it in GitHub Desktop.

Select an option

Save pipermerriam/d02f97a8b2b6f0a000be to your computer and use it in GitHub Desktop.
Want to monitor the progress of a loop?
def monitor_progress(things, every=1000, message="Processing `{current}` of `{total}`"):
print "Beginning processing"
total = len(things)
for idx, thing in enumerate(things):
if not idx % every:
print message.format(current=idx, total=total)
yield thing
print "Finished processing"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment