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