Created
April 19, 2014 04:04
-
-
Save kylehg/11073750 to your computer and use it in GitHub Desktop.
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 log_enumerate(iterable, step=1): | |
"""Enumerate an iterable and log its progress""" | |
for i, obj in enumerate(iterable): | |
if i % step == 0: | |
print 'Processed %d objects' % i | |
yield i, obj | |
def log_iterate(iterable, step=1): | |
for _, obj in log_enumerate(iterable, step): | |
yield obj |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment