
April 30, 2009
12:20 a.m.
Tarek Ziadé wrote:
Hello
unless I missed it, I couldn't find a built-in to check if an object is iterable,
so I wrote this function :
def iterable(ob): try: iter(ob) except TypeError: return False return True
What about having such a built-in in Python ? (with the proper implementation if course)
hasattr(ob, '__iter__')