def safe_setattr ( obj , name , value ) : try : setattr ( obj , name , value ) return True except AttributeError : return False
how to deal python attributeerror
Attempt to setattr but catch AttributeErrors .
def safe_setattr(obj, name, value):
    """Attempt to setattr but catch AttributeErrors."""
    try:
        setattr(obj, name, value)
        return True
    except AttributeError:
        return False