we can use hasattr method to check it and it will return boolean which it has that attr or not.
"hasattr(object,'__iter__')"
x = list() print(hasattr(x,'__iter__'))
Now, you can check object is iterable or not. Hope that it will be useful.
|
Hi, I'm Veerapat Sriarunrungrueang, an expert in technology field, especially full stack web development and performance testing.This is my coding diary. I usually develop and keep code snippets or some tricks, and update to this diary when I have time.
Nowadays, I've been giving counsel to many well-known firms in Thailand.
view more... |
x = list() print(hasattr(x,'__iter__'))
No comments:
Post a Comment