[Python-Dev] 'hasattr' is broken by design

Greg Ewing greg.ewing at canterbury.ac.nz
Wed Aug 25 02:10:02 CEST 2010


Steven D'Aprano wrote:

> But that's the thing... as far as I am concerned, a dynamically defined 
> attribute *doesn't* exist.

Maybe for your particular use case, but the concept of
whether an attribute is dynamically defined or not is
not well-defined in general.

Consider an object that is trying to be a transparent
proxy for another object, and behave as much as possible
as though it really were the other object. Should an
attribute statically defined on the proxied object be
considered dynamically defined on the proxy? If so, then
the proxy isn't as transparent as some people may want.

-- 
Greg


More information about the Python-Dev mailing list