Use 'hasattr()' rather than 3-arg 'getattr()'.

Incorporates feedback from @craigcitro. See:
https://github.com/craigcitro/apitools/pull/11/files#r20564006.