def is_seq ( obj ) : return ( not is_str ( obj ) and not is_dict ( obj ) and ( hasattr ( obj , "__getitem__" ) or hasattr ( obj , "__iter__" ) ) )
how to determine if a variable is as sequence in python
Check if an object is a sequence .
def is_seq(obj):
    """
    Check if an object is a sequence.
    """
    return (not is_str(obj) and not is_dict(obj) and
            (hasattr(obj, "__getitem__") or hasattr(obj, "__iter__")))