from collections import Iterable def iterable(obj): return isinstance(obj, Iterable)
from collections.abc import Iterable data = [] if isinstance(data, Iterable): pass # data is iterable