[openstack-dev] [Review] Use of exception for non-exceptional cases

Robert Collins robertc at robertcollins.net
Sat Jul 13 10:34:25 UTC 2013


On 11 July 2013 20:50, Mark McLoughlin <markmc at redhat.com> wrote:

>
> That answer does begin with this, though:
>
>   I almost always use hasattr: it's the correct choice for most cases.

I have to disagree here, hasattr is basically a timebomb. Three-param
getattr, or safe_hasattr are *much* better choices in every case I've
seen so far.

(safe_hasattr is in extras, or I believe there is a copy in oslo now).

-Rob


-- 
Robert Collins <rbtcollins at hp.com>
Distinguished Technologist
HP Cloud Services



More information about the OpenStack-dev mailing list