Skip to content

Commit

Permalink
Added a doctest for bucket (#36)
Browse files Browse the repository at this point in the history
  • Loading branch information
cjrh committed Jun 24, 2021
1 parent 19b00e8 commit f4ee8b7
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion excitertools.py
Original file line number Diff line number Diff line change
Expand Up @@ -2193,7 +2193,22 @@ def split_when(self, pred):
return Iter(more_itertools.split_when(self.x, pred))

def bucket(self, key, validator=None):
""" Docstring TBD """
"""
This is the basic example, copied from the more-itertools
docs:
.. code-block:: python
>>> iterable = ['a1', 'b1', 'c1', 'a2', 'b2', 'c2', 'b3']
>>> b = Iter(iterable).bucket(key=lambda x: x[0])
>>> sorted(b)
['a', 'b', 'c']
>>> list(b['a'])
['a1', 'a2']
Note that once consumed, you can't iterate over the contents
of a group again.
"""

class _bucket(more_itertools.bucket):
def __iter__(self):
Expand Down

0 comments on commit f4ee8b7

Please sign in to comment.