In Python, how do I determine if an object is iterable?

Is there a method like isiterable? The only solution I have found so far is to call

hasattr(myObj, '__iter__')

But I am not sure how fool-proof this is.

2
22

Leave a Comment