Thomas Lotze wrote:
> Jim Fulton <[EMAIL PROTECTED]> wrote:
>> I would change it to just use getattr rather than hasattr.
>> getattr(ob, name)
>> except AttributeError:
>> return False
> This doesn't handle the case that the attribute exists as a property
> but raises an AttributeError when trying to produce its value.
Yes, but this is still better than hasattr() which eats all exceptions.
I think eating AttributeErrors is fine because to the user of 'ob', it
would seem that ob.attr wouldn't exist anyway if it threw an
AttributeError (even if that exception was about something else, it's
still an AttributeError).
I suggest doing
marker = object()
return getattr(ob, name, marker) is marker
return hasattr(ob, name)
Zope-Dev maillist - Zope-Dev@zope.org
** No cross posts or HTML encoding! **
(Related lists -