Use getattr() instead of hasattr() since it does one less lookup.