Sprawdź, czy obiekt ma atrybut w Pythonie
if hasattr(a, 'property'):
doStuff(a.property)
else:
otherStuff()
DreamCoder
if hasattr(a, 'property'):
doStuff(a.property)
else:
otherStuff()
getattr(a, 'property', 'default value')
assert hasattr(a, 'property'), 'object lacks property'
print(a.property)