check if class attribute exists python code example
Example 1: python check if attribute exists in class
if hasattr(obj, 'propertyName'):
...
Example 2: python3 check if object has attribute
try:
doStuff(a.property)
except AttributeError:
otherStuff()