Calvin Spealman wrote:
> I will have to disagree with you there. If hasattr(a,b) returns True,
> one should be able to expect a.b will work properly. Otherwise, the
> majority of use cases for hasattr will be completely thrown out the
> window. How can hasattr work properly with properties if it d
Guido van Rossum wrote:
> Um, that does't work for types which customize __getattribute__ or
> __getattr__ in various ways.
There could be a __hasattr__ slot in the class itself for
that purpose.
> IMO a property that has a side effect (other than updating a cache or
> statistics or perhaps logg
On 12/7/05, Greg Ewing <[EMAIL PROTECTED]> wrote:
> Thomas Lotze wrote:
>
> > Apparently, when applied to a class instance, hasattr calls getattr and
> > decides that the attribute doesn't exist if the call raises any exception.
> > - Wouldn't it make sense to only report a missing attribute if an
On 12/7/05, Greg Ewing <[EMAIL PROTECTED]> wrote:
> Maybe descriptors need a fourth slot for hasattr
> customisation?
>
> The logic would then be
>
>if there is a descriptor for the attribute:
> if the descriptor's hasattr slot is populated:
>return the result of calling it
>
Thomas Lotze wrote:
> Apparently, when applied to a class instance, hasattr calls getattr and
> decides that the attribute doesn't exist if the call raises any exception.
> - Wouldn't it make sense to only report a missing attribute if an
> AttributeError is raised?
That would be an improvement