Skip to content

Commit

Permalink
Added of_enumerate
Browse files Browse the repository at this point in the history
  • Loading branch information
smarties committed May 1, 2018
1 parent b4c5c3e commit c388532
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
14 changes: 12 additions & 2 deletions mps/__init__.py
Expand Up @@ -6,6 +6,16 @@
from .mwt import MemoizeWithTimeout
from .errorrecoveryfile import ErrorRecoveryFile
from .simplecache import SimpleCache
from .of_enumerate import of_enumerate

__all__ = ['randstr', 'hdcache', 'all_days', 'work_days', 'deco_logger',
'MemoizeWithTimeout', 'ErrorRecoveryFile', 'SimpleCache']
__all__ = [
'randstr',
'hdcache',
'all_days',
'work_days',
'deco_logger',
'MemoizeWithTimeout',
'ErrorRecoveryFile',
'SimpleCache',
'of_enumerate',
]
8 changes: 8 additions & 0 deletions mps/of_enumerate.py
@@ -0,0 +1,8 @@
def of_enumerate(the_list):
zfills = len(str(len(the_list)))
length_list = len(the_list)
for i, item in enumerate(the_list):
i = str(i + 1).zfill(zfills)
yield '{i} / {length_list}'.format(i=i, length_list=length_list), item

raise StopIteration

0 comments on commit c388532

Please sign in to comment.