mirror of https://github.com/mahmoud/boltons.git
Merge branch 'master' of github.com:mahmoud/boltons
This commit is contained in:
commit
91dcff60b4
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in New Issue