Use getattr instead of a longer conditional.