S
satoru
hi, all
i want to check if a variable is iterable like a list, how can i
implement this?
i want to check if a variable is iterable like a list, how can i
implement this?
satoru said:hi, all
i want to check if a variable is iterable like a list, how can i
implement this?
this would be one way, though I'm sure others exist:
if hasattr(yourVar, '__iter__'):
# do stuff
satoru said:hi, all
i want to check if a variable is iterable like a list, how can i
implement this?
thank you,but this will miss out sequences like string just because it
doesn't have an attribute named '__iter__'
satoru said:thank you,but this will miss out sequences like string just because it
doesn't have an attribute named '__iter__'
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.