Merge branch 'master' of github.com:mahmoud/boltons

This commit is contained in:
Mahmoud Hashemi 2015-05-18 21:02:27 -07:00
commit 91dcff60b4
2 changed files with 11 additions and 1 deletions

View File

@ -165,7 +165,6 @@ def chunked(src, size, count=None, **kw):
else:
return list(itertools.islice(chunk_iter, count))
def chunked_iter(src, size, **kw):
"""Generates *size*-sized chunks from *src* iterable. Unless the
optional *fill* keyword argument is provided, iterables not even
@ -213,6 +212,15 @@ def chunked_iter(src, size, **kw):
yield postprocess(cur_chunk)
return
def pairwise(src, count=None, **kw):
"""Shortcut for calling chunked with size set to 2
"""
return chunked(src, 2, count, **kw)
def pairwise_iter(src, **kw):
"""Shortcut for calling chunked_iter with size set to 2
"""
return chunked_iter(src, 2, **kw)
def windowed(src, size):
"""Returns tuples with exactly length *size*. If the iterable is

View File

@ -14,6 +14,8 @@ from the standard library.
.. autofunction:: split_iter
.. autofunction:: chunked
.. autofunction:: chunked_iter
.. autofunction:: pairwise
.. autofunction:: pairwise_iter
.. autofunction:: windowed
.. autofunction:: windowed_iter