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
>      else:
>        return True
>    else:
>      look in the instance dict for the attribute

Um, that does't work for types which customize __getattribute__ or
__getattr__ in various ways.

IMO a property that has a side effect (other than updating a cache or
statistics or perhaps logging) is a misfeature anyway, so I don't see
what's wrong with hasattr() trying getattr() and reporting False IFF
that raises an exception.

If you want only AttributeError to be handled, use getattr(x, 'name', None).

--
--Guido van Rossum (home page: http://www.python.org/~guido/)
_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to