Is there a way to check for an instance (any instance) of a specific class in a list?
Checking list for class instance
2 replies to this topic
Members - Reputation: 2109
Posted 06 March 2012 - 05:24 PM
for element in thelist: if isinstance(element, TheClass): print 'found an instance'
The usual warnings apply; you shouldn't typically have to care about the exact type of an object, only the behaviours it supports. Consider your design carefully.