def is_iterable ( obj ) : return ( hasattr ( obj , "__iter__" ) and not isinstance ( obj , str ) and not isinstance ( obj , tuple ) )
python 'nonetype' object is not iterable
Are we being asked to look up a list of things instead of a single thing? We check for the __iter__ attribute so that this can cover types that don t have to be known by this module such as NumPy arrays .
def is_iterable(obj):
    """
    Are we being asked to look up a list of things, instead of a single thing?
    We check for the `__iter__` attribute so that this can cover types that
    don't have to be known by this module, such as NumPy arrays.

    Strings, however, should be considered as atomic values to look up, not
    iterables. The same goes for tuples, since they are immutable and therefore
    valid entries.

    We don't need to check for the Python 2 `unicode` type, because it doesn't
    have an `__iter__` attribute anyway.
    """
    return (
        hasattr(obj, "__iter__")
        and not isinstance(obj, str)
        and not isinstance(obj, tuple)
    )