How to test if object is sequence, or iterable?
Terry Reedy
tjreedy at udel.edu
Sat Jul 22 15:09:49 EDT 2006
"Tim N. van der Leeuw" <tim.leeuwvander at nl.unisys.com> wrote in message
news:1153587482.812348.320630 at h48g2000cwc.googlegroups.com...
> 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().
How about
try: it = iter(possible_iterable)
except TypeError: bail()
Terry Jan Reedy
More information about the Python-list
mailing list