(func, exception, first=None)
Call a function repeatedly until an exception is raised.

    Converts a call-until-exception interface to an iterator interface.
    Like __builtin__.iter(func, sentinel) but uses an exception instead
    of a sentinel to end the loop.
Call a function repeatedly until an exception is raised.
Call a function repeatedly until an exception is raised .
def iter_except(func, exception, first=None):
    """Call a function repeatedly until an exception is raised.

    Converts a call-until-exception interface to an iterator interface.
    Like __builtin__.iter(func, sentinel) but uses an exception instead
    of a sentinel to end the loop.
    """
    try:
        if first is not None:
            yield first()
        while True:
            yield func()
    except exception:
        pass
def iter_except ( func , exception , first = None ) : try : if first is not None : yield first ( ) while True : yield func ( ) except exception : pass