Quick wins for a faster PC:
Fix the driver behind crashes, sound loss and screen glitchesFind Drivers →Clear out junk files and repair common Windows errorsFree Scan →Scan for outdated or missing drivers - takes under a minuteDriver Scan →To check whether Python can iterate over an object, call iter(obj). If Python cannot obtain an iterator, it raises TypeError; catch that exception when you need a Boolean result. This runtime test also handles objects that use Python’s legacy sequence-iteration protocol.
Use iter() for a runtime check
Python’s documentation identifies iter(obj) as the reliable way to determine whether an object is iterable. A successful call means Python obtained an iterator at that moment. If the object does not support iteration, Python raises TypeError.
def is_iterable(obj):
try:
iter(obj)
except TypeError:
return False
return True
For example, is_iterable([1, 2, 3]) returns True, while is_iterable(42) returns False. The check obtains an iterator; it does not consume values from that iterator.
When to use collections.abc.Iterable
If you specifically want to check whether a value advertises or is registered with the Iterable interface, use isinstance():
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
#1 Best Overall
from collections.abc import Iterable
isinstance([1, 2, 3], Iterable) # True
However, this is an interface classification, not a complete runtime test. The Iterable ABC recognizes classes that provide __iter__ and types registered with the ABC, but it can miss objects that support iteration through the legacy sequence protocol: defining __getitem__ to return successive items until it raises IndexError. For that reason, prefer iter(obj) when your question is whether Python can actually iterate over a particular value. The distinction is documented in the Python 3.13 collections.abc documentation.
Quick Recap
Best Value
Rank #2
What the check does—and does not—prove
- It may run object code. Calling
iter(obj)can invoke a custom__iter__method or, for legacy sequence-style objects,__getitem__. It is not necessarily a side-effect-free inspection. - It does not guarantee a later operation will succeed. The check establishes that an iterator could be obtained at that moment; it does not prove that iteration will complete or that every value yielded will meet your needs.
- Iterators are iterable. An iterator supports the iterable protocol and adds
__next__to produce values. - Asynchronous iteration is separate.
iter(obj)checks ordinary iteration, not the asynchronous protocol associated with__aiter__.
Choose the check that matches your purpose
| Approach | Use it when | Important limitation |
|---|---|---|
iter(obj), catching TypeError |
You need to know whether Python can obtain an iterator for this value. | May invoke user-defined behavior. |
isinstance(obj, collections.abc.Iterable) |
You need to classify a value against the advertised or registered ABC interface. | May not recognize legacy __getitem__-only iteration. |
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.




