I would like to suggest avoid this:
try:
doStuff(a.property)
except AttributeError:
otherStuff()
The user @jpalecek mentioned it: If an AttributeError
occurs inside doStuff()
, you are lost.
Maybe this approach is better:
try:
val = a.property
except AttributeError:
otherStuff()
else:
doStuff(val)