Re: [matplotlib-devel] matplotlib.cbook.iterable

2011-03-23 Thread Michael Droettboom
TypeError: return False return True From: Jason Grout [jason-s...@creativetrax.com] Sent: Tuesday, March 22, 2011 11:27 PM To: matplotlib-devel@lists.sourceforge.net Subject: [matplotlib-devel] matplotlib.cbook.iterable The function matplotlib.cbook.iterab

Re: [matplotlib-devel] matplotlib.cbook.iterable

2011-03-23 Thread Ludwig Schwardt
Hi, In my code I have yet another version: def is_iterable(x): """Checks if object is iterable (but not a string).""" return hasattr(x, '__iter__') I specifically wanted to test for lists, tuples and numpy arrays, but not strings. Depending on the semantics of underscored methods could b

[matplotlib-devel] matplotlib.cbook.iterable

2011-03-22 Thread Jason Grout
The function matplotlib.cbook.iterable has the documentation: def iterable(obj): 'return true if *obj* is iterable' try: len(obj) except: return False return True However, in Sage, we have some objects that have __len__ defined, but are not iterable (i.e., they don't impleme