Tim N. van der Leeuw a écrit : > Hi, > > I'd like to know if there's a way to check if an object is a sequence, > or an iterable. Something like issequence() or isiterable(). > > Does something like that exist? (Something which, in case of iterable, > doesn't consume the first element of the iterable)
isiterable = lambda obj: isinstance(obj, basestring) \ or getattr(obj, '__iter__', False) Should cover most cases. -- http://mail.python.org/mailman/listinfo/python-list