\
        Get all choices listed from best match to worst match.

        If `group` is `True`, then matches are grouped based on their distance
        returned from `get_distance(target, choice)` and returned as an iterator.
        Otherwise, an iterator of all matches is returned.

        For example

        ::

           from howabout import all_matches

           choices = ['pot', 'cat', 'bat']

           for group in all_matches('hat', choices, group=True):
              print(list(group))

           # ['bat', 'cat']
           # ['pot']


        :param target:    a string
        :param choices:   a list or iterable of strings to compare with
                          `target` string
        :param group:     if `True`, group

def all_matches(self, target, choices, group=False, include_rank=False):
        """\
        Get all choices listed from best match to worst match.

        If `group` is `True`, then matches are grouped based on their distance
        returned from `get_distance(target, choice)` and returned as an iterator.
        Otherwise, an iterator of all matches is returned.

        For example

        ::

           from howabout import all_matches

           choices = ['pot', 'cat', 'bat']

           for group in all_matches('hat', choices, group=True):
              print(list(group))

           # ['bat', 'cat']
           # ['pot']


        :param target:    a string
        :param choices:   a list or iterable of strings to compare with
                          `target` string
        :param group:     if `True`, group
        """

        dist = self.get_distance

        # Keep everything here as an iterator in case we're given a lot of
        # choices
        matched = ((dist(target, choice), choice) for choice in choices)
        matched = sorted(matched)

        if group:
            for rank, choices in groupby(matched, key=lambda m: m[0]):
                yield map(lambda m: m[1], choices)
        else:
            for rank, choice in matched:
                yield choice