def weave_sets(set_n, set_m):
    """Return an iterator for set_n and set_m that stops when set_n is
    exhausted.  If set_n is larger than set_m, cycle over set_m.
    """
    m = len(set_m)
    if not m:
        raise ValueError("Set to be cycled on cannot be empty.")
    for i in range(len(set_n)):
        yield set_n[i], set_m[i%m]
    # In Python 2.3, this can be simplified to:
    #for index, item in enumerate(set_n):
    #    yield item, set_m[index%m]
Return an iterator for set_n and set_m that stops when set_n is
    exhausted.  If set_n is larger than set_m, cycle over set_m.
    
recipes/Python/139210_repeating_alternator/recipe-139210.py