Answers for "Python check iterable"

1

python check if variable is iterable

from collections import Iterable

def iterable(obj):
    return isinstance(obj, Iterable)
Posted by: Guest on September-13-2020
1

check iterable python

hasattr(myObj, '__iter__')
Posted by: Guest on July-03-2021
0

how to check if an object is iterable in python

try:
  obj = iter(obj)
  
 except:
  raise TypeError("obj is not iterable")
  
finally:
  print ("obj is iterable")
  
from collections import Iterable

if isinstance(obj, Iterable):
  print ("obj is iterable")
  
else:
  print ("obj is not iterable")
Posted by: Guest on March-28-2020

Python Answers by Framework

Browse Popular Code Answers by Language