disgrating a list
Tal Einat
tal.no.no.spam at gmail.com
Fri Sep 1 14:26:24 EDT 2006
Tim Chase wrote:
> I'm not sure if '__iter__' is the right thing to be looking for,
> but it seems to work at least for lists, sets, dictionarys (via
> their keys), etc. I would use it because at least then you know
> you can iterate over it
AFAIK and as seen throughout posts on c.l.py, the best way to check if
something is iterable is:
try:
iter(obj)
except TypeError:
<obj is not iterable>
else:
<obj is iterable>
- Tal
More information about the Python-list
mailing list