def compact(iterable, generator=False):
    """ Returns a list where all None values have been discarded. """
    if generator:
        return (val for val in iterable if val is not None)
    else:
        return [val for val in iterable if val is not None]