
In Python versions older than 3.2 hasattr is not robust as it masks real errors. And usually is not efficient as a call to hasattr is often followed by another call to getattr. It is best to avoid using it completely. See https://docs.python.org/3/whatsnew/3.2.html#other-language-changes