def listify(g):
    """Decorator that gathers generator results and returns a list."""
    def _listify(*args, **kwargs):
        r = g(*args, **kwargs)
        try:
            i = iter(r)
        except TypeError:
            # not iterable, pass through is better than raising here
            return r
        else:
            return list(i)
    return _listify