def repeatedly(f, n=None):
    """
    Takes a function of no args, presumably with side effects, and returns an
    infinite (or length ``n`` if supplied) lazy sequence of calls to it.
    """
    if callable(n) and isinstance(f, int):
        f, n = n, f
    if n is None:
        n = -1
    while n != 0:
        yield f()
        n -= 1
