Created
May 8, 2014 16:42
-
-
Save pipermerriam/d02f97a8b2b6f0a000be to your computer and use it in GitHub Desktop.
Want to monitor the progress of a loop?
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
| 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