def defaultiter(it, default):
    """This wraps an iterable so that if it's empty,
    it will return a default value instead."""
    empty = True
    for i in it:
        yield i
        empty = False
    if empty:
        yield default
