Python Check si la variable es iterable
from collections import Iterable
def iterable(obj):
return isinstance(obj, Iterable)
2Bowls
from collections import Iterable
def iterable(obj):
return isinstance(obj, Iterable)
hasattr(myObj, '__iter__')
try:
iterator = iter(the_element)
except TypeError:
# not iterable
else:
# iterable
# for obj in iterator:
# pass