def is_iterable(obj):
    """Returns whether a Python object is iterable."""
    typ = type(obj)
    if hasattr(typ, "__iter__"):
        return True
    return hasattr(typ, "__getitem__") and hasattr(typ, "__len__")