Python: check if an object is a sequence
iter(x) will raise a TypeError if x cannot be iterated on — but that check “accepts” sets and dictionaries, though it “rejects” other non-sequences such as None and numbers. On the other hands, strings (which most applications want to consider “single items” rather than sequences) are in fact sequences (so, any test, unless specialcased for … Read more