The function matplotlib.cbook.iterable has the documentation:
'return true if *obj* is iterable'
except: return False
However, in Sage, we have some objects that have __len__ defined, but are not iterable (i.e., they don't implement the iterator protocol). This is causing us problems when we try to plot some things that use this function, and matplotlib falsely assumes that the things are iterable. After checking around online, it seems that it is safer to check for iterability by doing something like:
except TypeError: return False
return isinstance(obj, collections.Iterable) # only works for new-style classes
Or maybe even combining these would be better (though it might be really redundant and slow, after looking at the code in collections.Iterable...):
return isinstance(obj, collections.Iterable)
You guys are the python experts, though. What do you think?