Snippets tagged “duck-typing”
1 snippet uses this tag.
- In Python, how do I determine if an object is iterable?Python
In Python, an object is considered iterable if it has an __iter__() method defined or if it has a __getitem__() method with defined indices (i.e., it can be indexed, like a list or a string).